mscorlib(4.0.0.0) API with additions
System.Threading.CountdownEvent Class Reference

Represents a synchronization primitive that is signaled when its count reaches zero. More...

Inheritance diagram for System.Threading.CountdownEvent:
[legend]
Collaboration diagram for System.Threading.CountdownEvent:
[legend]

Public Member Functions

 CountdownEvent (int initialCount)
 Initializes a new instance of T:System.Threading.CountdownEvent class with the specified count. More...
 
void Dispose ()
 Releases all resources used by the current instance of the T:System.Threading.CountdownEvent class. More...
 
bool Signal ()
 Registers a signal with the T:System.Threading.CountdownEvent, decrementing the value of P:System.Threading.CountdownEvent.CurrentCount. More...
 
bool Signal (int signalCount)
 Registers multiple signals with the T:System.Threading.CountdownEvent, decrementing the value of P:System.Threading.CountdownEvent.CurrentCount by the specified amount. More...
 
void AddCount ()
 Increments the T:System.Threading.CountdownEvent's current count by one. More...
 
bool TryAddCount ()
 Attempts to increment P:System.Threading.CountdownEvent.CurrentCount by one. More...
 
void AddCount (int signalCount)
 Increments the T:System.Threading.CountdownEvent's current count by a specified value. More...
 
bool TryAddCount (int signalCount)
 Attempts to increment P:System.Threading.CountdownEvent.CurrentCount by a specified value. More...
 
void Reset ()
 Resets the P:System.Threading.CountdownEvent.CurrentCount to the value of P:System.Threading.CountdownEvent.InitialCount. More...
 
void Reset (int count)
 Resets the P:System.Threading.CountdownEvent.InitialCount property to a specified value. More...
 
void Wait ()
 Blocks the current thread until the T:System.Threading.CountdownEvent is set. More...
 
void Wait (CancellationToken cancellationToken)
 Blocks the current thread until the T:System.Threading.CountdownEvent is set, while observing a T:System.Threading.CancellationToken. More...
 
bool Wait (TimeSpan timeout)
 Blocks the current thread until the T:System.Threading.CountdownEvent is set, using a T:System.TimeSpan to measure the timeout. More...
 
bool Wait (TimeSpan timeout, CancellationToken cancellationToken)
 Blocks the current thread until the T:System.Threading.CountdownEvent is set, using a T:System.TimeSpan to measure the timeout, while observing a T:System.Threading.CancellationToken. More...
 
bool Wait (int millisecondsTimeout)
 Blocks the current thread until the T:System.Threading.CountdownEvent is set, using a 32-bit signed integer to measure the timeout. More...
 
bool Wait (int millisecondsTimeout, CancellationToken cancellationToken)
 Blocks the current thread until the T:System.Threading.CountdownEvent is set, using a 32-bit signed integer to measure the timeout, while observing a T:System.Threading.CancellationToken. More...
 

Protected Member Functions

virtual void Dispose (bool disposing)
 Releases the unmanaged resources used by the T:System.Threading.CountdownEvent, and optionally releases the managed resources. More...
 

Properties

int CurrentCount [get]
 Gets the number of remaining signals required to set the event. More...
 
int InitialCount [get]
 Gets the numbers of signals initially required to set the event. More...
 
bool IsSet [get]
 Indicates whether the T:System.Threading.CountdownEvent object's current count has reached zero.. More...
 
WaitHandle WaitHandle [get]
 Gets a T:System.Threading.WaitHandle that is used to wait for the event to be set. More...
 

Detailed Description

Represents a synchronization primitive that is signaled when its count reaches zero.

Definition at line 12 of file CountdownEvent.cs.

Constructor & Destructor Documentation

◆ CountdownEvent()

System.Threading.CountdownEvent.CountdownEvent ( int  initialCount)

Initializes a new instance of T:System.Threading.CountdownEvent class with the specified count.

Parameters
initialCountThe number of signals initially required to set the T:System.Threading.CountdownEvent.
Exceptions
T:System.ArgumentOutOfRangeExceptioninitialCount is less than 0.

Definition at line 83 of file CountdownEvent.cs.

Member Function Documentation

◆ AddCount() [1/2]

void System.Threading.CountdownEvent.AddCount ( )

Increments the T:System.Threading.CountdownEvent's current count by one.

Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.InvalidOperationExceptionThe current instance is already set.-or- P:System.Threading.CountdownEvent.CurrentCount is equal to or greater than F:System.Int32.MaxValue.

Definition at line 186 of file CountdownEvent.cs.

◆ AddCount() [2/2]

void System.Threading.CountdownEvent.AddCount ( int  signalCount)

Increments the T:System.Threading.CountdownEvent's current count by a specified value.

Parameters
signalCountThe value by which to increase P:System.Threading.CountdownEvent.CurrentCount.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.ArgumentOutOfRangeExceptionsignalCount is less than or equal to 0.
T:System.InvalidOperationExceptionThe current instance is already set.-or- P:System.Threading.CountdownEvent.CurrentCount is equal to or greater than F:System.Int32.MaxValue after count is incremented by signalCount.

Definition at line 210 of file CountdownEvent.cs.

◆ Dispose() [1/2]

void System.Threading.CountdownEvent.Dispose ( )

Releases all resources used by the current instance of the T:System.Threading.CountdownEvent class.

Implements System.IDisposable.

Definition at line 100 of file CountdownEvent.cs.

◆ Dispose() [2/2]

virtual void System.Threading.CountdownEvent.Dispose ( bool  disposing)
protectedvirtual

Releases the unmanaged resources used by the T:System.Threading.CountdownEvent, and optionally releases the managed resources.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

Definition at line 109 of file CountdownEvent.cs.

◆ Reset() [1/2]

void System.Threading.CountdownEvent.Reset ( )

Resets the P:System.Threading.CountdownEvent.CurrentCount to the value of P:System.Threading.CountdownEvent.InitialCount.

Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed..

Definition at line 258 of file CountdownEvent.cs.

◆ Reset() [2/2]

void System.Threading.CountdownEvent.Reset ( int  count)

Resets the P:System.Threading.CountdownEvent.InitialCount property to a specified value.

Parameters
countThe number of signals required to set the T:System.Threading.CountdownEvent.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has alread been disposed.
T:System.ArgumentOutOfRangeExceptioncount is less than 0.

Definition at line 269 of file CountdownEvent.cs.

◆ Signal() [1/2]

bool System.Threading.CountdownEvent.Signal ( )

Registers a signal with the T:System.Threading.CountdownEvent, decrementing the value of P:System.Threading.CountdownEvent.CurrentCount.

Returns
true if the signal caused the count to reach zero and the event was set; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.InvalidOperationExceptionThe current instance is already set.

Definition at line 123 of file CountdownEvent.cs.

◆ Signal() [2/2]

bool System.Threading.CountdownEvent.Signal ( int  signalCount)

Registers multiple signals with the T:System.Threading.CountdownEvent, decrementing the value of P:System.Threading.CountdownEvent.CurrentCount by the specified amount.

Parameters
signalCountThe number of signals to register.
Returns
true if the signals caused the count to reach zero and the event was set; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.ArgumentOutOfRangeExceptionsignalCount is less than 1.
T:System.InvalidOperationExceptionThe current instance is already set. -or- Or signalCount is greater than P:System.Threading.CountdownEvent.CurrentCount.

Definition at line 151 of file CountdownEvent.cs.

◆ TryAddCount() [1/2]

bool System.Threading.CountdownEvent.TryAddCount ( )

Attempts to increment P:System.Threading.CountdownEvent.CurrentCount by one.

Returns
true if the increment succeeded; otherwise, false. If P:System.Threading.CountdownEvent.CurrentCount is already at zero, this method will return false.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.InvalidOperationExceptionP:System.Threading.CountdownEvent.CurrentCount is equal to F:System.Int32.MaxValue.

Definition at line 197 of file CountdownEvent.cs.

◆ TryAddCount() [2/2]

bool System.Threading.CountdownEvent.TryAddCount ( int  signalCount)

Attempts to increment P:System.Threading.CountdownEvent.CurrentCount by a specified value.

Parameters
signalCountThe value by which to increase P:System.Threading.CountdownEvent.CurrentCount.
Returns
true if the increment succeeded; otherwise, false. If P:System.Threading.CountdownEvent.CurrentCount is already at zero this will return false.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.ArgumentOutOfRangeExceptionsignalCount is less than or equal to 0.
T:System.InvalidOperationExceptionThe current instance is already set.-or- P:System.Threading.CountdownEvent.CurrentCount + signalCount is equal to or greater than F:System.Int32.MaxValue.

Definition at line 227 of file CountdownEvent.cs.

◆ Wait() [1/6]

void System.Threading.CountdownEvent.Wait ( )

Blocks the current thread until the T:System.Threading.CountdownEvent is set.

Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.

Definition at line 291 of file CountdownEvent.cs.

◆ Wait() [2/6]

void System.Threading.CountdownEvent.Wait ( CancellationToken  cancellationToken)

Blocks the current thread until the T:System.Threading.CountdownEvent is set, while observing a T:System.Threading.CancellationToken.

Parameters
cancellationTokenThe T:System.Threading.CancellationToken to observe.
Exceptions
T:System.OperationCanceledExceptioncancellationToken has been canceled.
T:System.ObjectDisposedExceptionThe current instance has already been disposed. -or- The T:System.Threading.CancellationTokenSource that created cancellationToken has already been disposed.

Definition at line 302 of file CountdownEvent.cs.

◆ Wait() [3/6]

bool System.Threading.CountdownEvent.Wait ( TimeSpan  timeout)

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

Parameters
timeoutA T:System.TimeSpan that represents the number of milliseconds to wait, or a T:System.TimeSpan that represents -1 milliseconds to wait indefinitely.
Returns
true if the T:System.Threading.CountdownEvent was set; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.ArgumentOutOfRangeExceptiontimeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than F:System.Int32.MaxValue.

Definition at line 314 of file CountdownEvent.cs.

◆ Wait() [4/6]

bool System.Threading.CountdownEvent.Wait ( TimeSpan  timeout,
CancellationToken  cancellationToken 
)

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

Parameters
timeoutA T:System.TimeSpan that represents the number of milliseconds to wait, or a T:System.TimeSpan that represents -1 milliseconds to wait indefinitely.
cancellationTokenThe T:System.Threading.CancellationToken to observe.
Returns
true if the T:System.Threading.CountdownEvent was set; otherwise, false.
Exceptions
T:System.OperationCanceledExceptioncancellationToken has been canceled.
T:System.ObjectDisposedExceptionThe current instance has already been disposed. -or- The T:System.Threading.CancellationTokenSource that created cancellationToken has already been disposed.
T:System.ArgumentOutOfRangeExceptiontimeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than F:System.Int32.MaxValue.

Definition at line 334 of file CountdownEvent.cs.

◆ Wait() [5/6]

bool System.Threading.CountdownEvent.Wait ( int  millisecondsTimeout)

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

Parameters
millisecondsTimeoutThe number of milliseconds to wait, or F:System.Threading.Timeout.Infinite(-1) to wait indefinitely.
Returns
true if the T:System.Threading.CountdownEvent was set; otherwise, false.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.
T:System.ArgumentOutOfRangeExceptionmillisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

Definition at line 351 of file CountdownEvent.cs.

◆ Wait() [6/6]

bool System.Threading.CountdownEvent.Wait ( int  millisecondsTimeout,
CancellationToken  cancellationToken 
)

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

Parameters
millisecondsTimeoutThe number of milliseconds to wait, or F:System.Threading.Timeout.Infinite(-1) to wait indefinitely.
cancellationTokenThe T:System.Threading.CancellationToken to observe.
Returns
true if the T:System.Threading.CountdownEvent was set; otherwise, false.
Exceptions
T:System.OperationCanceledExceptioncancellationToken has been canceled.
T:System.ObjectDisposedExceptionThe current instance has already been disposed. -or- The T:System.Threading.CancellationTokenSource that created cancellationToken has already been disposed.
T:System.ArgumentOutOfRangeExceptionmillisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

Definition at line 366 of file CountdownEvent.cs.

Property Documentation

◆ CurrentCount

int System.Threading.CountdownEvent.CurrentCount
get

Gets the number of remaining signals required to set the event.

Returns
The number of remaining signals required to set the event.

Definition at line 26 of file CountdownEvent.cs.

◆ InitialCount

int System.Threading.CountdownEvent.InitialCount
get

Gets the numbers of signals initially required to set the event.

Returns
The number of signals initially required to set the event.

Definition at line 43 of file CountdownEvent.cs.

◆ IsSet

bool System.Threading.CountdownEvent.IsSet
get

Indicates whether the T:System.Threading.CountdownEvent object's current count has reached zero..

Returns
true if the current count is zero; otherwise, false.

Definition at line 56 of file CountdownEvent.cs.

◆ WaitHandle

WaitHandle System.Threading.CountdownEvent.WaitHandle
get

Gets a T:System.Threading.WaitHandle that is used to wait for the event to be set.

Returns
A T:System.Threading.WaitHandle that is used to wait for the event to be set.
Exceptions
T:System.ObjectDisposedExceptionThe current instance has already been disposed.

Definition at line 69 of file CountdownEvent.cs.


The documentation for this class was generated from the following file: