9 [DebuggerDisplay(
"Initial Count={InitialCount}, Current Count={CurrentCount}")]
10 [__DynamicallyInvokable]
11 [HostProtection(
SecurityAction.LinkDemand, Synchronization =
true, ExternalThreading =
true)]
14 private int m_initialCount;
16 private volatile int m_currentCount;
20 private volatile bool m_disposed;
24 [__DynamicallyInvokable]
27 [__DynamicallyInvokable]
30 int currentCount = m_currentCount;
31 if (currentCount >= 0)
41 [__DynamicallyInvokable]
44 [__DynamicallyInvokable]
47 return m_initialCount;
54 [__DynamicallyInvokable]
57 [__DynamicallyInvokable]
60 return m_currentCount <= 0;
67 [__DynamicallyInvokable]
70 [__DynamicallyInvokable]
82 [__DynamicallyInvokable]
89 m_initialCount = initialCount;
90 m_currentCount = initialCount;
92 if (initialCount == 0)
99 [__DynamicallyInvokable]
108 [__DynamicallyInvokable]
109 protected virtual void Dispose(
bool disposing)
122 [__DynamicallyInvokable]
126 if (m_currentCount <= 0)
150 [__DynamicallyInvokable]
153 if (signalCount <= 0)
162 currentCount = m_currentCount;
163 if (currentCount < signalCount)
173 if (currentCount == signalCount)
185 [__DynamicallyInvokable]
196 [__DynamicallyInvokable]
209 [__DynamicallyInvokable]
226 [__DynamicallyInvokable]
229 if (signalCount <= 0)
237 int currentCount = m_currentCount;
238 if (currentCount <= 0)
242 if (currentCount >
int.MaxValue - signalCount)
257 [__DynamicallyInvokable]
260 Reset(m_initialCount);
268 [__DynamicallyInvokable]
276 m_currentCount = count;
277 m_initialCount = count;
290 [__DynamicallyInvokable]
301 [__DynamicallyInvokable]
304 Wait(-1, cancellationToken);
313 [__DynamicallyInvokable]
317 if (num < -1 || num >
int.MaxValue)
333 [__DynamicallyInvokable]
337 if (num < -1 || num >
int.MaxValue)
341 return Wait((
int)num, cancellationToken);
350 [__DynamicallyInvokable]
351 public bool Wait(
int millisecondsTimeout)
365 [__DynamicallyInvokable]
368 if (millisecondsTimeout < -1)
377 flag = m_event.
Wait(millisecondsTimeout, cancellationToken);
382 private void ThrowIfDisposed()
bool Signal()
Registers a signal with the T:System.Threading.CountdownEvent, decrementing the value of P:System....
Represents a synchronization primitive that is signaled when its count reaches zero.
void Dispose()
Releases all resources used by the current instance of the T:System.Threading.ManualResetEventSlim cl...
Propagates notification that operations should be canceled.
Encapsulates operating system–specific objects that wait for exclusive access to shared resources.
void ThrowIfCancellationRequested()
Throws a T:System.OperationCanceledException if this token has had cancellation requested.
CountdownEvent(int initialCount)
Initializes a new instance of T:System.Threading.CountdownEvent class with the specified count.
static void SuppressFinalize(object obj)
Requests that the common language runtime not call the finalizer for the specified object.
Provides support for spin-based waiting.
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
bool Wait(int millisecondsTimeout, CancellationToken cancellationToken)
Blocks the current thread until the T:System.Threading.CountdownEvent is set, using a 32-bit signed i...
int InitialCount
Gets the numbers of signals initially required to set the event.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
bool TryAddCount(int signalCount)
Attempts to increment P:System.Threading.CountdownEvent.CurrentCount by a specified value.
int CurrentCount
Gets the number of remaining signals required to set the event.
void Wait(CancellationToken cancellationToken)
Blocks the current thread until the T:System.Threading.CountdownEvent is set, while observing a T:Sys...
double TotalMilliseconds
Gets the value of the current T:System.TimeSpan structure expressed in whole and fractional milliseco...
WaitHandle WaitHandle
Gets the underlying T:System.Threading.WaitHandle object for this T:System.Threading....
void Wait()
Blocks the current thread until the current T:System.Threading.ManualResetEventSlim is set.
virtual void Dispose(bool disposing)
Releases the unmanaged resources used by the T:System.Threading.CountdownEvent, and optionally releas...
The exception that is thrown when an operation is performed on a disposed object.
SecurityAction
Specifies the security actions that can be performed using declarative security.
Provides information about, and means to manipulate, the current environment and platform....
void Set()
Sets the state of the event to signaled, which allows one or more threads waiting on the event to pro...
void AddCount()
Increments the T:System.Threading.CountdownEvent's current count by one.
void Reset()
Resets the P:System.Threading.CountdownEvent.CurrentCount to the value of P:System....
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
bool IsSet
Indicates whether the T:System.Threading.CountdownEvent object's current count has reached zero....
bool Signal(int signalCount)
Registers multiple signals with the T:System.Threading.CountdownEvent, decrementing the value of P:Sy...
Provides a slimmed down version of T:System.Threading.ManualResetEvent.
bool Wait(TimeSpan timeout)
Blocks the current thread until the T:System.Threading.CountdownEvent is set, using a T:System....
void AddCount(int signalCount)
Increments the T:System.Threading.CountdownEvent's current count by a specified value.
void Reset(int count)
Resets the P:System.Threading.CountdownEvent.InitialCount property to a specified value.
Controls the system garbage collector, a service that automatically reclaims unused memory.
bool TryAddCount()
Attempts to increment P:System.Threading.CountdownEvent.CurrentCount by one.
void SpinOnce()
Performs a single spin.
void Wait()
Blocks the current thread until the T:System.Threading.CountdownEvent is set.
Represents a time interval.To browse the .NET Framework source code for this type,...
The exception that is thrown when a method call is invalid for the object's current state.
void Dispose()
Releases all resources used by the current instance of the T:System.Threading.CountdownEvent class.
static int Decrement(ref int location)
Decrements a specified variable and stores the result, as an atomic operation.
void Reset()
Sets the state of the event to nonsignaled, which causes threads to block.
bool Wait(int millisecondsTimeout)
Blocks the current thread until the T:System.Threading.CountdownEvent is set, using a 32-bit signed i...
Provides atomic operations for variables that are shared by multiple threads.
bool Wait(TimeSpan timeout, CancellationToken cancellationToken)
Blocks the current thread until the T:System.Threading.CountdownEvent is set, using a T:System....