AsyncCrossProcessMutex.TryEnterAsync(TimeSpan) 方法

定義

以異步方式取得 mutex,允許逾時而不擲回例外狀況。

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))

參數

timeout
TimeSpan

逾時前等候的最大時間。不使用 InfiniteTimeSpan 逾時,或 Zero 只有在立即可用時,才取得 mutex。

傳回

如果已取得 mutex,則結果會是一個值,其處置將會釋放 mutex。 發生逾時,會產生 null 值。

例外狀況

如果 timeout 不是 -1 毫秒以外的負數,則從等候的結果擲回,這代表無限逾時。

如果在先前呼叫這個方法之前呼叫 ,則會擲回,如果輸入 mutex,則會將其 releaser 處置。

適用於