Let’s assume I have following console application:
Thread thread = new Thread(new ThreadStart(() => { throw new Exception(); }));
thread.IsBackground = true;
thread.Start();
while (true)
Console.WriteLine("Hello from main thread");
Is it possible to make entire application not crashing because of background tread’s exception (without using try..catch of course)?
Attach your unhandled exceptions handler:
http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx
The better way you can achieve desired result (Ok, with try/catch, but only once) with global handler:
And then start your threads:
P.S. However, really, I don’t like idea of catching all exceptions. It is almost never good idea.