Gionata
Gionata

Reputation: 1673

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

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.

Upvotes: 155

Views: 321917

Answers (7)

Yahia
Yahia

Reputation: 70369

If your application uses threads directly or indirectly (i.e. behind the scenes 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.

Upvotes: 7

shanansari
shanansari

Reputation: 1

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.

Upvotes: -7

BlueM
BlueM

Reputation: 6888

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.

Upvotes: 251

tonyb
tonyb

Reputation: 449

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.

Upvotes: 2

alphanoch
alphanoch

Reputation: 201

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

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

Upvotes: 15

JoGusto
JoGusto

Reputation: 973

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.

Upvotes: 1

Kek
Kek

Reputation: 3195

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.

Upvotes: 23

Related Questions