What are the methods and properties of the Thread class in C#?

CsharpProgrammingServer Side Programming

Threads are lightweight processes. One common example of use of thread is implementation of concurrent programming by modern operating systems.

The following are some of the properties of the Thread class −

Sr.No.Property & Description
1CurrentContext
Gets the current context in which the thread is executing.
2CurrentCulture
Gets or sets the culture for the current thread.
3CurrentPrinciple
Gets or sets the thread's current principal (for role-based security).
4CurrentThread
Gets the currently running thread.
5CurrentUICulture
Gets or sets the current culture used by the Resource Manager to look up culture-specific resources at run-time.
6ExecutionContext
Gets an ExecutionContext object that contains information about the various contexts of the current thread.
7IsAlive
Gets a value indicating the execution status of the current thread.
8IsBackground
Gets or sets a value indicating whether or not a thread is a background thread.

The following are the methods of the Thread class −

Sr.No.Method & Description
1public void Abort()
Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of terminating the thread. Calling this method usually terminates the thread.
2public static LocalDataStoreSlot AllocateDataSlot()
Allocates an unnamed data slot on all the threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.
3public static LocalDataStoreSlot AllocateNamedDataSlot(string name)
Allocates a named data slot on all threads. For better performance, use fields that are marked with the ThreadStaticAttribute attribute instead.
4public static void BeginCriticalRegion()
Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception might jeopardize other tasks in the application domain.
5public static void BeginThreadAffinity()
Notifies a host that managed code is about to execute instructions that depend on the identity of the current physical operating system thread.
6public static void EndCriticalRegion()
Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception are limited to the current task.
7public static void EndThreadAffinity()
Notifies a host that managed code has finished executing instructions that depend on the identity of the current physical operating system thread.
raja
Published on 09-Aug-2018 09:07:03
Advertisements