我在我的 Winforms 应用程序中收到了大量这些消息,尽管我从未明确创建任何线程。为什么会这样?我四处寻找解释,但很难用这样的方式来表达询问。
我使用的是 Visual Studios 2013,这是我关心的调试输出:
The thread 0x23a4 has exited with code 259 (0x103).
The thread 0x2884 has exited with code 259 (0x103).
The thread 0x27ec has exited with code 259 (0x103).
The thread 0x1978 has exited with code 259 (0x103).
The thread 0x1534 has exited with code 259 (0x103).
The thread 0x1ad8 has exited with code 259 (0x103).
The thread 0x2938 has exited with code 259 (0x103).
The thread 0x22c8 has exited with code 259 (0x103).
最佳答案
来自 MSDN 文档:
Remarks
This function returns immediately. If the specified thread has not terminated and the function succeeds, the status returned is STILL_ACTIVE. If the thread has terminated and the function succeeds, the status returned is one of the following values: The exit value specified in the ExitThread or TerminateThread function. The return value from the thread function. The exit value of the thread's process. Important The GetExitCodeThread function returns a valid error code defined by the application only after the thread terminates. Therefore, an application should not use STILL_ACTIVE (259) as an error code. If a thread returns STILL_ACTIVE (259) as an error code, applications that test for this value could interpret it to mean that the thread is still running and continue to test for the completion of the thread after the thread has terminated, which could put the application into an infinite loop.
所以基本上它仍然不时地检查当前线程。
这似乎是一个错误:
关于c# - 为什么我会看到多条 "The thread 0x22c8 has exited with code 259 (0x103)."消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22395396/