c# - 为什么我会看到多条 "The thread 0x22c8 has exited with code 259 (0x103)."消息

标签 c# multithreading visual-studio exit-code

我在我的 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.

所以基本上它仍然不时地检查当前线程。

这似乎是一个错误:

http://connect.microsoft.com/VisualStudio/feedback/details/812144/vs2013-reports-incorrect-thread-exit-code

关于c# - 为什么我会看到多条 "The thread 0x22c8 has exited with code 259 (0x103)."消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22395396/

相关文章:

visual-studio - Azure Functions Visual Studio 2017 15.3 错误

android - VS 2015 RC Apache Cordova 空白 appTemplate 构建失败

c# - 安全地将变量值从一个页面传递到另一个页面

c# - 为什么不对 switch 语句强制执行显式 fall-through 而不是显式 break?

c# - 可能的 HeroCard 或 Azure 测试 Web 聊天图像缓存问题

Python 使用 subprocess.Popen 关闭所有线程或进程

java - 如何在 Spring Batch 中设置多线程?

c# - 当前在 C# 中跟踪程序流的可能性?

android - Android中的线程导致手机崩溃

visual-studio - 有没有办法在 Visual Studio 2010 中快速查找文件?