/// Gets a semi-unique identifier for this monitor.
/// </summary>
publicintId
{
get{return_asyncLock.Id;}
}
/// <summary>
/// Asynchronously enters the monitor. Returns a disposable that leaves the monitor when disposed.
/// </summary>
/// <param name="cancellationToken">The cancellation token used to cancel the enter. If this is already set, then this method will attempt to enter the monitor immediately (succeeding if the monitor is currently available).</param>
/// <returns>A disposable that leaves the monitor when disposed.</returns>
/// Synchronously enters the monitor. Returns a disposable that leaves the monitor when disposed. This method may block the calling thread.
/// </summary>
/// <param name="cancellationToken">The cancellation token used to cancel the enter. If this is already set, then this method will attempt to enter the monitor immediately (succeeding if the monitor is currently available).</param>
/// Asynchronously enters the monitor. Returns a disposable that leaves the monitor when disposed.
/// </summary>
/// <returns>A disposable that leaves the monitor when disposed.</returns>
publicTask<IDisposable>EnterAsync()
{
returnEnterAsync(CancellationToken.None);
}
/// <summary>
/// Asynchronously enters the monitor. Returns a disposable that leaves the monitor when disposed. This method may block the calling thread.
/// </summary>
publicIDisposableEnter()
{
returnEnter(CancellationToken.None);
}
/// <summary>
/// Asynchronously waits for a pulse signal on this monitor. The monitor MUST already be entered when calling this method, and it will still be entered when this method returns, even if the method is cancelled. This method internally will leave the monitor while waiting for a notification.
/// </summary>
/// <param name="cancellationToken">The cancellation signal used to cancel this wait.</param>
/// Asynchronously waits for a pulse signal on this monitor. This method may block the calling thread. The monitor MUST already be entered when calling this method, and it will still be entered when this method returns, even if the method is cancelled. This method internally will leave the monitor while waiting for a notification.
/// </summary>
/// <param name="cancellationToken">The cancellation signal used to cancel this wait.</param>
/// Asynchronously waits for a pulse signal on this monitor. The monitor MUST already be entered when calling this method, and it will still be entered when this method returns. This method internally will leave the monitor while waiting for a notification.
/// </summary>
publicTaskWaitAsync()
{
returnWaitAsync(CancellationToken.None);
}
/// <summary>
/// Asynchronously waits for a pulse signal on this monitor. This method may block the calling thread. The monitor MUST already be entered when calling this method, and it will still be entered when this method returns. This method internally will leave the monitor while waiting for a notification.
/// </summary>
publicvoidWait()
{
Wait(CancellationToken.None);
}
/// <summary>
/// Sends a signal to a single task waiting on this monitor. The monitor MUST already be entered when calling this method, and it will still be entered when this method returns.
/// </summary>
publicvoidPulse()
{
_conditionVariable.Notify();
}
/// <summary>
/// Sends a signal to all tasks waiting on this monitor. The monitor MUST already be entered when calling this method, and it will still be entered when this method returns.