Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 545 Bytes

File metadata and controls

15 lines (12 loc) · 545 Bytes

SerialQueue

Lightweight C# implementation of FIFO serial queues from ObjC, which is often much better to use for synchronization rather than locks - it doesn't block caller's thread, and than creating new thread - it uses thread pool.

private readonly SerialQueue queue = new SerialQueue();

async Task SomeAsyncMethod()
{
  // C# 5
  var result = await queue.Enqueue(LongRunningWork);

  // Old approach
  queue.Enqueue(LongRunningWork).ContinueWith(t => {
      var result = t.Result;
  })
}