Thread Class
Namespace: System.Threading
Assembly: System.Threading.dll
Constructors
Thread(ThreadStart start)
Initializes a new instance of the Thread
class.
Thread(ThreadStart start, int maxStackSize)
Initializes a new instance of the Thread
class with the specified stack size.
Thread(ParameterizedThreadStart start)
Initializes a new instance of the Thread
class with a delegate that calls a method containing parameters.
Thread(ParameterizedThreadStart start, int maxStackSize)
Initializes a new instance of the Thread
class with a delegate that calls a method containing parameters and the specified stack size.
Fields
public static ThreadCurrentThread { get; }
Gets the Thread
on which the current thread is executing.
public static extern int ManagedThreadId { get; }
Gets the unique identifier for the current thread.
Properties
public ApartmentState ApartmentState { get; set; }
Gets or sets the apartment state of the thread.
public string Name { get; set; }
Gets or sets a name for the current thread.
public ThreadPriority Priority { get; set; }
Gets or sets a value indicating the priority of this thread.
public ThreadState ThreadState { get; }
Gets the state of the current thread.
Methods
public void Abort()
Schedules the thread to be aborted.
public static void BeginThreadAffinity()
Sets the current thread to be globally thread-bound to the current operating system thread.
public static void EndThreadAffinity()
Resets the thread affinity to that of the current thread.
public void Join()
Blocks the calling thread until the thread terminates.
public void Resume()
Resumes a thread that has been suspended by a call to Suspend()
.
public void Start()
Starts the execution of the thread, following any initialization requirements.
public void Start(object parameter)
Starts the execution of the thread, using the specified parameter.
public void Suspend()
Suspends the thread.
public void Terminate()
Attempts to terminate the thread.
Events
public event ThreadStart ThreadStateChanged;
Occurs when the state of the thread changes.
public static event ThreadExceptionEventHandler ThreadException;
Occurs when an unhandled Exception
is thrown by a thread.