<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.1.2" />

Nito.AsyncEx.AsyncAutoResetEvent

public sealed class AsyncAutoResetEvent
An async-compatible auto-reset event.
public int Id { get; }

Gets a semi-unique identifier for this asynchronous auto-reset event.

public bool IsSet { get; }

Whether this event is currently set. This member is seldom used; code using this member has a high possibility of race conditions.

public AsyncAutoResetEvent(bool set)

Creates an async-compatible auto-reset event.

Creates an async-compatible auto-reset event that is initially unset.

public void Set()

Sets the event, atomically completing a task returned by WaitAsync. If the event is already set, this method does nothing.

public void Wait(CancellationToken cancellationToken)

Synchronously waits for this event to be set. If the event is set, this method will auto-reset it and return immediately, even if the cancellation token is already signalled. If the wait is canceled, then it will not auto-reset this event. This method may block the calling thread.

public void Wait()

Synchronously waits for this event to be set. If the event is set, this method will auto-reset it and return immediately. This method may block the calling thread.

public Task WaitAsync(CancellationToken cancellationToken)

Asynchronously waits for this event to be set. If the event is set, this method will auto-reset it and return immediately, even if the cancellation token is already signalled. If the wait is canceled, then it will not auto-reset this event.

public Task WaitAsync()

Asynchronously waits for this event to be set. If the event is set, this method will auto-reset it and return immediately.