System.Threading Namespace
Classes
C Thread
Represents a thread, which is a single sequential flow of control in a process. The Thread class is used to create and manage threads.
Members:
C CancellationTokenSource
Notifies operations that they should be canceled. This class is used to signal cancellation and to register callbacks that should be executed when cancellation is requested.
Members:
C ManualResetEvent
Signals one or more threads that an event has occurred. This class provides a simple way to synchronize threads.
Members:
C SemaphoreSlim
Represents a confining construct that limits the number of threads that can access a resource or perform an action concurrently. This is a lightweight semaphore, optimized for intra-process synchronization.
Members:
Interfaces
I IThreadLocal
Represents a value that is local to a thread. This interface is used for implementing thread-local storage.
I ICancellationToken
Represents a token that can be used to signal cancellation.
Enums
E ThreadState
Specifies the execution state of a thread.
Values:
Running
Stopped
Suspended
Aborted
WaitSleepJoin
Suspended
Background
Unstarted
Stopped
Suspended
AbortRequested
StopRequested
SuspendRequested
ResumeRequested
Static Members
P Thread.CurrentThread
Gets the currently executing thread.
P Thread.ManagedThreadId
Gets a unique identifier for the current managed thread.
P Thread.IsBackground
Gets or sets a value indicating whether a thread is a background thread. If this property is true, the thread is a background thread, and it will not prevent the application from exiting when all threads are either stopped or are background threads. If this property is false, the thread is a foreground thread, and the application will not exit until the thread has terminated.
M Thread.Start()
Updates the status of the thread to Running, unless the thread has already been started.
M Thread.Sleep(int millisecondsTimeout)
Suspends the current thread for the specified number of milliseconds.
M CancellationTokenSource.Cancel()
Communicates a notification that this CancellationTokenSource has requested cancellation.
P CancellationTokenSource.IsCancellationRequested
Gets whether cancellation has been requested for this CancellationTokenSource.
P CancellationTokenSource.Token
Gets the CancellationToken associated with this CancellationTokenSource.
M ManualResetEvent.Set()
Sets the state of the event to signaled, allowing one or more waiting threads to proceed.
M ManualResetEvent.Reset()
Sets the state of the event to nonsignaled, causing threads to block.
M ManualResetEvent.WaitOne()
Blocks the current thread until the current instance receives a signal.
M SemaphoreSlim.WaitAsync()
Asynchronously decrements the current SemaphoreSlim count, blocking the calling thread until it can do so.
M SemaphoreSlim.Release()
Releases the semaphore one count, thereby releasing one waiting thread or fulfilling one asynchronous wait.