Share via


AsyncCrossProcessMutex.TryEnterAsync(TimeSpan) Method

Definition

Acquires the mutex asynchronously, allowing for timeouts without throwing exceptions.

public System.Threading.Tasks.Task<Microsoft.VisualStudio.Threading.AsyncCrossProcessMutex.LockReleaser?> TryEnterAsync (TimeSpan timeout);
member this.TryEnterAsync : TimeSpan -> System.Threading.Tasks.Task<Nullable<Microsoft.VisualStudio.Threading.AsyncCrossProcessMutex.LockReleaser>>
Public Function TryEnterAsync (timeout As TimeSpan) As Task(Of Nullable(Of AsyncCrossProcessMutex.LockReleaser))

Parameters

timeout
TimeSpan

The maximum time to wait before timing out. Use InfiniteTimeSpan for no timeout, or Zero to acquire the mutex only if it is immediately available.

Returns

If the mutex was acquired, the result is a value whose disposal will release the mutex. In the event of a timeout, the result in a null value.

Exceptions

Thrown from the awaited result if the timeout is a negative number other than -1 milliseconds, which represents an infinite timeout.

Thrown if called before a prior call to this method has completed, with its releaser disposed if the mutex was entered.

Applies to