CountdownEvent.Wait Method

Definition

Blocks the current thread until the CountdownEvent is set.

Overloads

Wait()

Blocks the current thread until the CountdownEvent is set.

Wait(Int32)

Blocks the current thread until the CountdownEvent is set, using a 32-bit signed integer to measure the timeout.

Wait(CancellationToken)

Blocks the current thread until the CountdownEvent is set, while observing a CancellationToken.

Wait(TimeSpan)

Blocks the current thread until the CountdownEvent is set, using a TimeSpan to measure the timeout.

Wait(Int32, CancellationToken)

Blocks the current thread until the CountdownEvent is set, using a 32-bit signed integer to measure the timeout, while observing a CancellationToken.

Wait(TimeSpan, CancellationToken)

Blocks the current thread until the CountdownEvent is set, using a TimeSpan to measure the timeout, while observing a CancellationToken.

Wait()

Source:
CountdownEvent.cs
Source:
CountdownEvent.cs
Source:
CountdownEvent.cs

Blocks the current thread until the CountdownEvent is set.

public void Wait ();
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public void Wait ();
Attributes

Exceptions

The current instance has already been disposed.

Remarks

The caller of this method blocks indefinitely until the current instance is set. The caller will return immediately if the event is currently in a set state.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

Wait(Int32)

Source:
CountdownEvent.cs
Source:
CountdownEvent.cs
Source:
CountdownEvent.cs

Blocks the current thread until the CountdownEvent is set, using a 32-bit signed integer to measure the timeout.

public bool Wait (int millisecondsTimeout);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait (int millisecondsTimeout);

Parameters

millisecondsTimeout
Int32

The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.

Returns

true if the CountdownEvent was set; otherwise, false.

Attributes

Exceptions

The current instance has already been disposed.

millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

Wait(CancellationToken)

Source:
CountdownEvent.cs
Source:
CountdownEvent.cs
Source:
CountdownEvent.cs

Blocks the current thread until the CountdownEvent is set, while observing a CancellationToken.

public void Wait (System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public void Wait (System.Threading.CancellationToken cancellationToken);

Parameters

cancellationToken
CancellationToken

The CancellationToken to observe.

Attributes

Exceptions

cancellationToken has been canceled.

The current instance has already been disposed.

-or-

The CancellationTokenSource that created cancellationToken has already been disposed.

Remarks

The caller of this method blocks indefinitely until the current instance is set. The caller will return immediately if the event is currently in a set state. If the CancellationToken being observed is canceled during the wait operation, an OperationCanceledException will be thrown.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

Wait(TimeSpan)

Source:
CountdownEvent.cs
Source:
CountdownEvent.cs
Source:
CountdownEvent.cs

Blocks the current thread until the CountdownEvent is set, using a TimeSpan to measure the timeout.

public bool Wait (TimeSpan timeout);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait (TimeSpan timeout);

Parameters

timeout
TimeSpan

A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Returns

true if the CountdownEvent was set; otherwise, false.

Attributes

Exceptions

The current instance has already been disposed.

timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than Int32.MaxValue.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

Wait(Int32, CancellationToken)

Source:
CountdownEvent.cs
Source:
CountdownEvent.cs
Source:
CountdownEvent.cs

Blocks the current thread until the CountdownEvent is set, using a 32-bit signed integer to measure the timeout, while observing a CancellationToken.

public bool Wait (int millisecondsTimeout, System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait (int millisecondsTimeout, System.Threading.CancellationToken cancellationToken);

Parameters

millisecondsTimeout
Int32

The number of milliseconds to wait, or Infinite(-1) to wait indefinitely.

cancellationToken
CancellationToken

The CancellationToken to observe.

Returns

true if the CountdownEvent was set; otherwise, false.

Attributes

Exceptions

cancellationToken has been canceled.

The current instance has already been disposed. -or- The CancellationTokenSource that created cancellationToken has already been disposed.

millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

Wait(TimeSpan, CancellationToken)

Source:
CountdownEvent.cs
Source:
CountdownEvent.cs
Source:
CountdownEvent.cs

Blocks the current thread until the CountdownEvent is set, using a TimeSpan to measure the timeout, while observing a CancellationToken.

public bool Wait (TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait (TimeSpan timeout, System.Threading.CancellationToken cancellationToken);

Parameters

timeout
TimeSpan

A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

cancellationToken
CancellationToken

The CancellationToken to observe.

Returns

true if the CountdownEvent was set; otherwise, false.

Attributes

Exceptions

cancellationToken has been canceled.

The current instance has already been disposed. -or- The CancellationTokenSource that created cancellationToken has already been disposed.

timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than Int32.MaxValue.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0