What happens if an unhandled exception is raised in a multicast delegate? : IAsyncResult : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » IAsyncResult »

 

What happens if an unhandled exception is raised in a multicast delegate?








    
 

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");
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» IAsyncResult