Advertisement
magnusbakken

Untitled

Feb 12th, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. public static class Program
  5. {
  6.     public static void Main()
  7.     {
  8.         AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
  9.         FailInThread();
  10.     }
  11.  
  12.     private static void FailInThread()
  13.     {
  14.         ParameterizedThreadStart start = _ => { throw new Exception(); };
  15.         Thread thread = new Thread(start);
  16.         thread.Start();
  17.         thread.Join();
  18.     }
  19.  
  20.     private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  21.     {
  22.         Console.WriteLine("Caught {0}", e.ExceptionObject.GetType());
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement