AsyncCrossProcessMutex.TryEnterAsync(TimeSpan) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
非同步取得互斥體,允許逾時且不拋出例外。
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立即可用時取得。
傳回
若互斥體被取得,結果為一個數值,其處置將釋放互斥體。
若發生超時,結果會產生一個 null 值。
例外狀況
若 為 timeout 負數,非 -1 毫秒,則從等待結果中剔除,該時間代表無限次逾時。
若在先前呼叫完成前被呼叫時會拋棄;若進入互斥線,則釋放器會被丟棄。