CountdownEvent.Wait 方法

定義

阻塞目前執行緒直到設定 CountdownEvent 完成。

多載

名稱 Description
Wait()

阻塞目前執行緒直到設定 CountdownEvent 完成。

Wait(Int32)

會阻塞目前執行緒直到設定完成, CountdownEvent 並使用 32 位元有符號整數來測量逾時。

Wait(CancellationToken)

在觀察 一個 CountdownEvent時,阻塞當前執行緒直到 被CancellationToken設定為止。

Wait(TimeSpan)

阻塞目前執行緒直到設定 CountdownEvent 完成,並使用 a TimeSpan 來測量逾時。

Wait(Int32, CancellationToken)

會阻塞目前執行緒直到設定完成,CountdownEvent並使用一個 32 位元的有符號整數來測量逾時,同時觀察 。CancellationToken

Wait(TimeSpan, CancellationToken)

在設定 之前阻塞目前執行緒 CountdownEvent ,並使用 a TimeSpan 來測量逾時,同時觀察 CancellationToken

Wait()

來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs

阻塞目前執行緒直到設定 CountdownEvent 完成。

public:
 void Wait();
public void Wait();
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public void Wait();
member this.Wait : unit -> unit
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : unit -> unit
Public Sub Wait ()
屬性

例外狀況

目前的實例已經被處理完畢。

備註

此方法的呼叫者會無限阻擋,直到目前實例被設定為止。 如果事件目前處於設定狀態,呼叫者會立即返回。

另請參閱

適用於

Wait(Int32)

來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs

會阻塞目前執行緒直到設定完成, CountdownEvent 並使用 32 位元有符號整數來測量逾時。

public:
 bool Wait(int millisecondsTimeout);
public bool Wait(int millisecondsTimeout);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait(int millisecondsTimeout);
member this.Wait : int -> bool
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : int -> bool
Public Function Wait (millisecondsTimeout As Integer) As Boolean

參數

millisecondsTimeout
Int32

等待的毫秒數,或 Infinite(-1)無限等待的毫秒數。

傳回

trueCountdownEvent 為 ,則為 false

屬性

例外狀況

目前的實例已經被處理完畢。

millisecondsTimeout 是除 -1 以外的負數,而 -1 代表無限次超時。

另請參閱

適用於

Wait(CancellationToken)

來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs

在觀察 一個 CountdownEvent時,阻塞當前執行緒直到 被CancellationToken設定為止。

public:
 void Wait(System::Threading::CancellationToken cancellationToken);
public void Wait(System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public void Wait(System.Threading.CancellationToken cancellationToken);
member this.Wait : System.Threading.CancellationToken -> unit
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : System.Threading.CancellationToken -> unit
Public Sub Wait (cancellationToken As CancellationToken)

參數

cancellationToken
CancellationToken

CancellationToken觀察。

屬性

例外狀況

cancellationToken 已經取消了。

目前的實例已經被處理完畢。

-或-

CancellationTokenSource那個已經被cancellationToken處理掉的。

備註

此方法的呼叫者會無限阻擋,直到目前實例被設定為止。 如果事件目前處於設定狀態,呼叫者會立即返回。 若觀察到的CancellationToken被觀察者在等待操作中被取消,則會拋出 。OperationCanceledException

另請參閱

適用於

Wait(TimeSpan)

來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs

阻塞目前執行緒直到設定 CountdownEvent 完成,並使用 a TimeSpan 來測量逾時。

public:
 bool Wait(TimeSpan timeout);
public bool Wait(TimeSpan timeout);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait(TimeSpan timeout);
member this.Wait : TimeSpan -> bool
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : TimeSpan -> bool
Public Function Wait (timeout As TimeSpan) As Boolean

參數

timeout
TimeSpan

TimeSpan A 代表等待的毫秒數,或 A TimeSpan 代表無限等待的 -1 毫秒。

傳回

trueCountdownEvent 為 ,則為 false

屬性

例外狀況

目前的實例已經被處理完畢。

timeout 是除 -1 毫秒外的負數值,代表無限次逾時 -或逾時大於 Int32.MaxValue

另請參閱

適用於

Wait(Int32, CancellationToken)

來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs

會阻塞目前執行緒直到設定完成,CountdownEvent並使用一個 32 位元的有符號整數來測量逾時,同時觀察 。CancellationToken

public:
 bool Wait(int millisecondsTimeout, System::Threading::CancellationToken cancellationToken);
public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken);
member this.Wait : int * System.Threading.CancellationToken -> bool
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : int * System.Threading.CancellationToken -> bool
Public Function Wait (millisecondsTimeout As Integer, cancellationToken As CancellationToken) As Boolean

參數

millisecondsTimeout
Int32

等待的毫秒數,或 Infinite(-1)無限等待的毫秒數。

cancellationToken
CancellationToken

CancellationToken觀察。

傳回

trueCountdownEvent 為 ,則為 false

屬性

例外狀況

cancellationToken 已經取消了。

目前的實例已經被處理完畢。 -或者- CancellationTokenSource 那個已經 cancellationToken 被處理掉了。

millisecondsTimeout 是除 -1 以外的負數,而 -1 代表無限次超時。

另請參閱

適用於

Wait(TimeSpan, CancellationToken)

來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs
來源:
CountdownEvent.cs

在設定 之前阻塞目前執行緒 CountdownEvent ,並使用 a TimeSpan 來測量逾時,同時觀察 CancellationToken

public:
 bool Wait(TimeSpan timeout, System::Threading::CancellationToken cancellationToken);
public bool Wait(TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait(TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.Wait : TimeSpan * System.Threading.CancellationToken -> bool
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : TimeSpan * System.Threading.CancellationToken -> bool
Public Function Wait (timeout As TimeSpan, cancellationToken As CancellationToken) As Boolean

參數

timeout
TimeSpan

TimeSpan A 代表等待的毫秒數,或 A TimeSpan 代表無限等待的 -1 毫秒。

cancellationToken
CancellationToken

CancellationToken觀察。

傳回

trueCountdownEvent 為 ,則為 false

屬性

例外狀況

cancellationToken 已經取消了。

目前的實例已經被處理完畢。 -或者- CancellationTokenSource 那個已經 cancellationToken 被處理掉了。

timeout 是除 -1 毫秒外的負數值,代表無限次逾時 -或逾時大於 Int32.MaxValue

另請參閱

適用於