ThreadState 枚举

定义

指定线程的当前执行状态。Specifies the current execution state of the thread.

public enum class ThreadState
public enum ThreadState
type ThreadState = 
Public Enum ThreadState
继承
ThreadState

字段

Initialized 0

此状态指示线程已初始化但尚未启动。A state that indicates the thread has been initialized, but has not yet started.

Ready 1

此状态指示线程因无可用的处理器而等待使用处理器。A state that indicates the thread is waiting to use a processor because no processor is free. 线程准备在下一个可用的处理器上运行。The thread is prepared to run on the next available processor.

Running 2

此状态指示线程当前正在使用处理器。A state that indicates the thread is currently using a processor.

Standby 3

此状态指示线程将要使用处理器。A state that indicates the thread is about to use a processor. 一次只能有一个线程处于此状态。Only one thread can be in this state at a time.

Terminated 4

此状态指示线程已完成执行并已退出。A state that indicates the thread has finished executing and has exited.

Transition 6

此状态指示线程在可以执行前等待处理器之外的资源。A state that indicates the thread is waiting for a resource, other than the processor, before it can execute. 例如,它可能正在等待其执行堆栈从磁盘中分页。For example, it might be waiting for its execution stack to be paged in from disk.

Unknown 7

线程的状态未知。The state of the thread is unknown.

Wait 5

此状态指示线程尚未准备好使用处理器,因为它正在等待外围操作完成或等待资源释放。A state that indicates the thread is not ready to use the processor because it is waiting for a peripheral operation to complete or a resource to become free. 当线程就绪后,将对其进行重排。When the thread is ready, it will be rescheduled.

注解

重要

有两个线程状态枚举: System.Diagnostics.ThreadStateSystem.Threading.ThreadStateThere are two thread state enumerations, System.Diagnostics.ThreadState and System.Threading.ThreadState. 只有几个调试方案才会对线程状态枚举感兴趣。The thread state enumerations are only of interest in a few debugging scenarios. 因此,始终不应在代码中使用线程状态来同步线程活动。Your code should never use thread state to synchronize the activities of threads.

适用于

另请参阅