16.1. The System.Threading Namespace

System.Threading is the namespace where all thread-related C# classes reside. The following tables list the classes (Table 16.1), delegates (Table 16.2), and enumerations (Table 16.3) of this namespace.

The following sections discuss the key classes, delegates, and enumerations in the namespace.

Table 16.1. System.Threading Classes
ClassDescription
AutoResetEventNotifies one or more waiting threads that an event has occurred. This class cannot be inherited.
InterlockedProvides atomic operations for variables that are shared by multiple threads.
ManualResetEventOccurs when one or more waiting threads are notified that an event has occurred. This class cannot be inherited.
MonitorProvides a mechanism that synchronizes access to objects.
MutexA synchronization primitive that can also be used for interprocess synchronization.
ReaderWriterLockDefines the lock that implements single-writer and multiple-reader semantics.
RegisteredWaitHandleRepresents a handle that has been registered when calling RegisterWaitForSingleObject. This class cannot be inherited.
SynchronizationLockExceptionThe exception that is thrown when a synchronized method is invoked from an unsynchronized block of code.
ThreadCreates and controls a thread, sets its priority, and gets its status.
ThreadAbortExceptionThe exception that is thrown when a call is made to the Abort method. This class cannot be inherited.
ThreadExceptionEventArgsProvides data for the ThreadException event.
ThreadInterruptedExceptionThe exception that is thrown when a thread is interrupted while it is in a waiting state.
ThreadPoolProvides 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.
ThreadStateExceptionThe exception that is thrown when a thread is in an invalid ThreadState for the method call.
TimeoutContains a constant used to specify an infinite amount of time. This class cannot be inherited.
TimerProvides a mechanism for executing methods at specified intervals. This class cannot be inherited.
WaitHandleEncapsulates operating-system-specific objects that wait for exclusive access to shared resources.

Table 16.2. System.Threading Delegates
DelegateDescription
IOCompletionCallbackReceives the error code, number of bytes, and overlapped value type when an I/O operation completes on the thread pool.
ThreadExceptionEventHandlerRepresents the method that will handle the ThreadException event of an application.
ThreadStartRepresents the method that will handle the Start event of the Thread class.
TimerCallbackRepresents the method that will handle the state of a Timer.
WaitCallbackDefines the callback method for thread pool user work items. That method must match this delegate.
WaitOrTimerCallbackReceives a Boolean parameter that determines whether the handle was signaled or the WaitHandle timed out.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.151.141