C Sharp Thread class

C# Thread class

C# Thread class is found in the System.Threading namespace, to facilitate properties and methods to create and control threads.

C# Thread Properties:

The most common properties of the Thread class are listed below:

CurrentThreadTo get the instance of currently running thread.
IsAliveTo determine whether the current thread is alive or not to find the execution status of the thread.
IsBackgroundTo retrieve or set the value whether current thread is in background or not.
ManagedThreadIdTo retrieve a unique id for the current managed thread.
NameTo retrieve or to set the name of the current thread.
PriorityTo retrieve or to set the priority of the current thread.
ThreadStateTo get a value representing the thread state.

C# Thread Methods:

The most common methods of the Thread class are listed below:

Abort()To terminate the thread and to raise the ThreadAbortException exception.
Interrupt()To interrupt a thread which is in WaitSleepJoin state.
Join()To block all the calling threads until this thread terminates.
ResetAbort()To cancel the Abort request for the current thread.
Resume()To resume the suspended thread. It is obsolete.
Sleep(Int32)To suspend the current thread for the specified milliseconds.
Start()To modify the current state of the thread to Runnable.
Suspend()To suspend the current thread if it is not suspended. It is obsolete.
Yield()To yield the execution of current thread to another thread.


Content Protection by DMCA.com
Please Share