3 public class FinallyTest {
4 public static void MyHandler(object sender,
5 UnhandledExceptionEventArgs args) {
7 Console.WriteLine("UnhandledExceptionEventHandler called");
10 public static void Main() {
11 Console.WriteLine("Top level block");
13 AppDomain domain = AppDomain.CurrentDomain;
14 domain.UnhandledException +=
15 new UnhandledExceptionEventHandler(MyHandler);
18 Console.WriteLine("First try block");
20 Console.WriteLine("Second try block");
21 throw new Exception();
23 Console.WriteLine("Second finally block");
26 Console.WriteLine("First finally block");
29 Console.WriteLine("Back to top level block");