2 using System.Threading;
4 public class FinalizerException {
5 ~FinalizerException () {
6 throw new Exception ();
9 public static int Main () {
10 AppDomain.CurrentDomain.UnhandledException += (sender, args) => {
11 Console.WriteLine ("caught");
15 new FinalizerException ();
18 GC.WaitForPendingFinalizers ();
20 Thread.Sleep (Timeout.Infinite); // infinite wait so we don't race against the unhandled exception callback