Skip to content

Commit afb5f02

Browse files
authored
Update README.md
1 parent ef97135 commit afb5f02

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,18 @@ using CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSec
3131
//acquire writer lock
3232
using var d2 = await asyncLock.WriterLockAsync("123", cts.Token);
3333

34-
//use writer lock scope
35-
36-
using var r1 = await asyncLock.ReaderLockAsync();
37-
38-
//use reader lock
39-
40-
if (..)
34+
//use writer lock scope to break long running reader lock
35+
using (var r1 = await lockEntity.ReaderLockAsync())
4136
{
42-
r1.UseWriterLockAsync(async () => { /*use writer lock here*/ });
43-
}
37+
//use reader lock
4438
45-
//continue with reader lock
39+
if (..)
40+
{
41+
r1.UseWriterLockAsync(async () => { /*use writer lock here*/ });
42+
}
4643

44+
//continue with reader lock
45+
}
4746
```
4847

4948
### Benchmarks

0 commit comments

Comments
 (0)