Skip to content

Instantly share code, notes, and snippets.

@jnicholls
Created December 3, 2013 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnicholls/7771803 to your computer and use it in GitHub Desktop.
Save jnicholls/7771803 to your computer and use it in GitHub Desktop.
SemaphoreSlim signal = new SemaphoreSlim(0, 1);
// set signal in event
signal.Release();
// wait for signal somewhere else
await signal.WaitAsync();
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
// complete task in event
tcs.SetResult(true);
// wait for task somewhere else
await tcs.Task;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment