ThreadA spawns ThreadB.
ThreadB throws an exception.
How can ThreadA know about this exception?
using System;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ThreadStart threadDelegate1 = new ThreadStart(MyClass1.DoThis);
Thread ThreadA = new Thread(threadDelegate1);
ThreadA.Start();
Thread.Sleep(100000); // this thread is doing something else here, sleep simulates it
}
}
class MyClass1
{
public static void DoThis()
{
try
{
ThreadStart threadDelegate1 = new ThreadStart(MyClass2.DoThat);
Thread ThreadB = new Thread(threadDelegate1);
ThreadB.Start();
Thread.Sleep(100000); // this thread is doing something else here, sleep simulates it
}
catch (Exception e)
{
// I want to know if something went wrong with MyClass2.DoThat
}
}
}
class MyClass2
{
public static void DoThat()
{
throw new Exception("From DoThat");
}
}
}