Unhandled exceptions that originate on background (or worker) threads will also terminate an application, just like unhandled exceptions that originate on the main thread.
In the example below, we execute the DoSomethingInBackground method on a background thread. Execution continues in parallel on the main thread, while the background thread is running.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | static void Main(string[] args){ Thread worker = new Thread(DoSomethingInBackground); <span class="skimlinks-unlinked">worker.Start</span>(); // Continue here immediately after launching background // worker Console.WriteLine("I've launched the worker!"); while (true) Console.WriteLine(Console.ReadLine());}static void DoSomethingInBackground(){ Console.WriteLine("DoSomething start"); <span class="skimlinks-unlinked">Thread.Sleep(3000</span>); Console.WriteLine("DoSomething middle"); <span class="skimlinks-unlinked">Thread.Sleep(3000</span>); throw new Exception("Oh no !"); Console.WriteLine("DoSomething end");} |
When the background thread throws an exception and we don’t handle it, the entire application (rather than just the background thread) is terminated.

