2 using System.Threading;
8 var d = AppDomain.CreateDomain("Foo");
9 d.ProcessExit += AppDomain_ProcessExit;
11 AppDomain.CurrentDomain.ProcessExit += new EventHandler (AppDomain_ProcessExit);
12 ThreadPool.QueueUserWorkItem (new WaitCallback (Proc));
16 static void Proc (object unused)
18 Thread.CurrentThread.IsBackground = false;
20 Console.WriteLine ("done");
23 static void AppDomain_ProcessExit (object sender, EventArgs e)
25 Console.WriteLine ("exit");
27 // No messages should be printed, as when this event is fired the
28 // ThreadPool has been shutdown, thus `a.BeginInvoke()` has no effect.
32 Console.WriteLine ("Ha! {0}", i++);
34 a.BeginInvoke (null, null);