The thread has exited with code 0 (0x0) with no unhandled exception

C#.NetDebugging

C# Problem Overview


While debugging my C# application I have noticed a large amount occurrences of the following sentence:

> The thread -- has exited with code 0 (0x0).

The application continues to work and no exception is catched/unhanded.

The application is running on Windows 7 64bit and debugged with x86 platform.

C# Solutions


Solution 1 - C#

This is just debugging message. You can switch that off by right clicking into the output window and uncheck Thread Exit Messages.

http://msdn.microsoft.com/en-us/library/bs4c1wda.aspx

> In addition to program out from your application, the Output window > can display the information about: > > > - Modules the debugger has loaded or unloaded. > > - Exceptions that are thrown. > > - Processes that exit. > > - Threads that exit.

Solution 2 - C#

Well, an application may have a lot of threads running in parallel. Some are run by you, the coder, some are run by framework classes (espacially if you are in a GUI environnement).

When a thread has finished its task, it exits and stops to exist. There ie nothing alarming in this and you should not care.

Solution 3 - C#

In order to complete BlueM's accepted answer, you can desactivate it here:

Tools > Options > Debugging > General Output Settings > Thread Exit Messages : Off

Solution 4 - C#

if your application uses threads directly or indirectly (i.e. behind the scene like in a 3rd-party library) it is absolutely common to have threads terminate after they are done... which is basically what you describe... the debugger shows this message... you can configure the debugger to not display this message if you don't want it...

If the above does not help then please provide more details since I am not sure what exactly the problem is you face...

Solution 5 - C#

Executing Linq queries can generate extra threads. When I try to execute code that uses Linq query collection in the immediate window it often refuses to run because not enough threads are available to the debugger.

As others have said, for threads to exit when they are finished is perfectly normal.

Solution 6 - C#

The framework creates threads to support each window you create, eg, as when you create a Form and .Show() it. When the windows close, the threads are terminated (ie, they exit).

This is normal behavior. However, if the application is creating threads, and there are a lot of thread exit messages corresponding to these threads (one could tell possibly by the thread's names, by giving them distinct names in the app), then perhaps this is indicative of a problem with the app creating threads when it shouldn't, due to a program logic error.

It would be an interesting followup to have the original poster let us know what s/he discovered regarding the problems with the server crashing. I have a feeling it wouldn't have anything to do with this... but it's hard to tell from the information posted.

Solution 7 - C#

Stop this error you have to follow this simple steps

  1. Open Visual Studio
  2. Select option debug from the top
  3. Select Options
  4. In Option Select debugging under debugging select General
  5. In General Select check box "Automatically close the console when debugging stop"
  6. Save it

Then Run the code by using Shortcut key Ctrl+f5

**Other wise it still show error when you run it direct

Solution 8 - C#

I have also faced this problem and the solution is:

  1. open Solution Explore
  2. double click on Program.cs file

I added this code again and my program ran accurately:

Application.Run(new PayrollSystem()); 
//File name this code removed by me accidentally.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGionataView Question on Stackoverflow
Solution 1 - C#BlueMView Answer on Stackoverflow
Solution 2 - C#KekView Answer on Stackoverflow
Solution 3 - C#alphanochView Answer on Stackoverflow
Solution 4 - C#YahiaView Answer on Stackoverflow
Solution 5 - C#tonybView Answer on Stackoverflow
Solution 6 - C#JoGustoView Answer on Stackoverflow
Solution 7 - C#Lijo GeorgeView Answer on Stackoverflow
Solution 8 - C#shanansariView Answer on Stackoverflow