简体   繁体   English

所有线程终止后,C#进程仍然存在

[英]C# process lingers after all threads have terminated

I have a multithreaded C# "console" application with lots of threads trhat finishes up. 我有一个多线程的C#“控制台”应用程序,有许多线程完成。 All my threads exit. 我的所有线程退出。 90% of the time the application gracefully exits. 应用程序正常退出的90%的时间。 But 10% of the time a copy of my application lingers: console still open. 但是,有10%的时间我的应用程序副本仍然存在:控制台仍然打开。

I attach to this via Visual Studio 2010 and use break to interrupt it, and am shown two "empty" stack frames: one for Main and one for one of my application-created threads. 我通过Visual Studio 2010附加到此并使用break来中断它,并显示两个“空”堆栈帧:一个用于Main,一个用于我的应用程序创建的线程。 Neither has anything on the stack. 堆栈上也没有任何东西。 Visual Studio says that "source code is not available for the thread" if I click on either of these threads, and it offers a "dissambled code view" link. 如果我点击这些线程中的任何一个,Visual Studio会说“源代码不可用于该线程”,并且它提供了“已解密的代码视图”链接。 I click on that and it says "disassembled code is not available for this thread". 我点击它,它说“反汇编的代码不适用于这个线程”。

Any ideas what I might be doing wrong? 我有什么想法可能做错了吗?

Does you code shut down after some extra minutes. 您是否在额外的几分钟后关闭代码。 It could be that some .net helper thead or garbage collection thread is still running. 可能是某些.net帮助器或垃圾收集线程仍在运行。 That might take some extra time. 这可能需要一些额外的时间。

Are you running a debug build or a release build and are you sure the process is not one of those visual studio hosted processes that keeps running for design purposes. 您是在运行调试版本还是发布版本,并且您确定该过程不是为了设计目的而继续运行的Visual Studio托管过程之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM