using System;
using System.Threading;
public delegate void DelegateClass();
public class Starter {
public static void Main() {
Console.WriteLine("Running on primary thread");
try {
DelegateClass del = MethodA;
IAsyncResult ar = del.BeginInvoke(null, null);
del.EndInvoke(ar);
} catch (Exception except) {
Console.WriteLine("Running on primary thread");
Console.WriteLine("Exception caught: " + except.Message);
}
}
public static void MethodA() {
if (Thread.CurrentThread.IsThreadPoolThread == true) {
Console.WriteLine("Running on a thread pool thread");
} else {
Console.WriteLine("Running on primary thread");
}
throw new Exception("failure");
}
}