/// Whether this event is currently set. This member is seldom used; code using this member has a high possibility of race conditions.
/// </summary>
publicboolIsSet
{
get{lock(_mutex)return_tcs.Task.IsCompleted;}
}
/// <summary>
/// Asynchronously waits for this event to be set.
/// </summary>
publicTaskWaitAsync()
{
lock(_mutex)
{
return_tcs.Task;
}
}
/// <summary>
/// Asynchronously waits for this event to be set or for the wait to be canceled.
/// </summary>
/// <param name="cancellationToken">The cancellation token used to cancel the wait. If this token is already canceled, this method will first check whether the event is set.</param>
/// Synchronously waits for this event to be set. This method may block the calling thread.
/// </summary>
publicvoidWait()
{
WaitAsync().WaitAndUnwrapException();
}
/// <summary>
/// Synchronously waits for this event to be set. This method may block the calling thread.
/// </summary>
/// <param name="cancellationToken">The cancellation token used to cancel the wait. If this token is already canceled, this method will first check whether the event is set.</param>
/// Sets the event, atomically completing every task returned by <see cref="O:Nito.AsyncEx.AsyncManualResetEvent.WaitAsync"/>. If the event is already set, this method does nothing.
/// </summary>
publicvoidSet()
{
lock(_mutex)
{
_tcs.TrySetResult(null);
}
}
/// <summary>
/// Resets the event. If the event is already reset, this method does nothing.