- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the methods and properties of the Thread class in C#?
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 |
---|---|
1 | CurrentContext Gets the current context in which the thread is executing. |
2 | CurrentCulture Gets or sets the culture for the current thread. |
3 | CurrentPrinciple Gets or sets the thread's current principal (for role-based security). |
4 | CurrentThread Gets the currently running thread. |
5 | CurrentUICulture Gets or sets the current culture used by the Resource Manager to look up culture-specific resources at run-time. |
6 | ExecutionContext Gets an ExecutionContext object that contains information about the various contexts of the current thread. |
7 | IsAlive Gets a value indicating the execution status of the current thread. |
8 | IsBackground 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 |
---|---|
1 | public 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. |
2 | public 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. |
3 | public 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. |
4 | public 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. |
5 | public 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. |
6 | public 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. |
7 | public 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. |
Advertisements