System.Threading Namespace
Microsoft Silverlight will reach end of support after October 2021. Learn more.
The System.Threading namespace provides classes and interfaces that enable multithreaded programming. In addition to classes for synchronizing thread activities and access to data (Monitor, Interlocked, AutoResetEvent, and so on), this namespace includes a ThreadPool class that enables you to use a pool of system-supplied threads, and a Timer class that executes callback methods on thread pool threads. In addition to the features provided in the System.Threading namespace, the BackgroundWorker class provides a simple, event-based way to synchronize access to the main application thread.
Classes
Class | Description | |
---|---|---|
AutoResetEvent | Notifies a waiting thread that an event has occurred. This class cannot be inherited. | |
CancellationTokenSource | Signals to a CancellationToken that it should be canceled. | |
EventWaitHandle | Represents a thread synchronization event. | |
Interlocked | Provides atomic operations for variables that are shared by multiple threads. | |
ManualResetEvent | Notifies one or more waiting threads that an event has occurred. This class cannot be inherited. | |
Monitor | Provides a mechanism that synchronizes access to objects. | |
Mutex | A synchronization primitive that can also be used for interprocess synchronization. | |
Overlapped | Provides a managed representation of a Win32 OVERLAPPED structure, including methods to transfer information from an Overlapped instance to a NativeOverlapped structure. | |
RegisteredWaitHandle | Represents a handle that has been registered when calling RegisterWaitForSingleObject. This class cannot be inherited. | |
SynchronizationContext | Provides the basic functionality for propagating a synchronization context in various synchronization models. | |
SynchronizationLockException | The exception that is thrown when a method requires the caller to own the lock on a given Monitor, and the method is invoked by a caller that does not own that lock. | |
Thread | Creates and controls a thread, and gets its status. | |
ThreadAbortException | The exception that is thrown when a call is made to the Abort method. This class cannot be inherited. | |
ThreadPool | Provides a pool of threads that can be used to post work items, process asynchronous I/O, wait on behalf of other threads, and process timers. | |
ThreadStartException | The exception that is thrown when a failure occurs in a managed thread after the underlying operating system thread has been started, but before the thread is ready to execute user code. | |
ThreadStateException | The exception that is thrown when a Thread is in an invalid ThreadState for the method call. | |
Timeout | Contains a constant that is used to specify an infinite amount of time. This class cannot be inherited. | |
Timer | Provides a mechanism for executing a method at specified intervals. This class cannot be inherited. | |
WaitHandle | Encapsulates operating system–specific objects that wait for exclusive access to shared resources. |
Structures
Structure | Description | |
---|---|---|
CancellationToken | Propagates notification that operations should be canceled. | |
CancellationTokenRegistration | Represents a callback delegate that has been registered with a CancellationToken. | |
NativeOverlapped | Provides an explicit layout that is visible from unmanaged code and that will have the same layout as the Win32 OVERLAPPED structure with additional reserved fields at the end. |
Delegates
Delegate | Description | |
---|---|---|
IOCompletionCallback | Receives the error code, number of bytes, and overlapped value type when an I/O operation completes on the thread pool. | |
ParameterizedThreadStart | Represents the method that executes on a Thread. | |
SendOrPostCallback | Represents a method to be called when a message is to be dispatched to a synchronization context. | |
ThreadStart | Represents the method that executes on a Thread. | |
TimerCallback | Represents the method that handles calls from a Timer. | |
WaitCallback | Represents a callback method to be executed by a thread pool thread. | |
WaitOrTimerCallback | Represents a method to be called when a WaitHandle is signaled or times out. |
Enumerations
Enumeration | Description | |
---|---|---|
LazyThreadSafetyMode | Specifies how a System.Lazy<T> instance synchronizes access among multiple threads. | |
ThreadState | Specifies the execution states of a Thread. |
See Also