Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# isBackground Thread is NOT terminating properly

I have one background thread I use for processing separately from the GUI, and everything works fine between the threads. However when I close the application, the program "closes" but does not kill the process. The background thread is keeping the program alive it seems.

I have set "myThreadInstance.IsBackground = true;", and I thought this would require C# to kill it when it is killed.

I am testing this all in Visual Studio (2010, using .NET 4.0), and after the first build, the rest all fail because the exe is still in use so it cannot overwrite it. Looking in task manager, it is there. Killing Visual Studio releases the vbhost process which releases my exe. Killing my exe's process, makes vbhost respawn it in a second or two.

like image 439
Nick Avatar asked Nov 14 '22 07:11

Nick


1 Answers

Actually, based on your description and other things you've tried (and their results), I believe the most likely cause is this:

You have another foreground thread in your application, other than the one you're examining.

like image 142
Stephen Cleary Avatar answered Nov 24 '22 01:11

Stephen Cleary