This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int Parallelism = 3; | |
const int NumItems = 20; | |
TimeSpan ProcessingTime = TimeSpan.FromMilliseconds(100); | |
Console.WriteLine("WorkQueue starting"); | |
await using (WorkQueue workQueue1 = new(Parallelism)) | |
{ | |
List<Task> tasks = new(NumItems); | |
for (int i = 0; i < NumItems; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class AsyncMutex : IAsyncDisposable | |
{ | |
private readonly string _name; | |
private Task? _mutexTask; | |
private ManualResetEventSlim? _releaseEvent; | |
private CancellationTokenSource? _cancellationTokenSource; | |
public AsyncMutex(string name) | |
{ | |
_name = name; |