I wrote this code snippet:
static void Main(string[] args)
{
Console.WriteLine("Start");
Thread secondThread = new Thread(ThrowAnException);
secondThread.Start();
Console.ReadKey();
}
static void ThrowAnException()
{
throw new Exception("Second Thread Exception");
}
}
My understanding is that when the exception happens on the second thread, the exception moves down the thread's stack and if unhandled, the child thread terminates silently. What I am seeing is that the thread is interrupting the main thread and breaking in the ThrowAnException method with an "Exception was Unhandled".
I ran it both with debugging and without and the behavor is the same.
Any ideas what I am doing wrong?