简体   繁体   中英

C# process lingers after all threads have terminated

I have a multithreaded C# "console" application with lots of threads trhat finishes up. All my threads exit. 90% of the time the application gracefully exits. But 10% of the time a copy of my application lingers: console still open.

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. 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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