2 using System
.Threading
;
5 This test checks if the AddDomain::DomainUnload event is processed with
6 a fully working domain. In special if the threadpool remains operational.
10 static void UnloadHook (object obj
, EventArgs args
)
12 ManualResetEvent evt
= new ManualResetEvent (false);
13 Console
.WriteLine ("On the UnloadHook");
14 if (Environment
.HasShutdownStarted
)
15 throw new Exception ("Environment.HasShutdownStarted must not be true");
16 Action
<int> f
= (int x
) => {
20 f
.BeginInvoke (1, null, null);
22 Console
.WriteLine ("Hook done");
25 static void OtherDomain()
27 AppDomain app
= AppDomain
.CurrentDomain
;
28 Console
.WriteLine ("Now I'm on {0}", app
);
29 app
.DomainUnload
+= Driver
.UnloadHook
;
34 AppDomain app
= AppDomain
.CreateDomain ("Foo");
35 Console
.WriteLine ("I'm on {0}", AppDomain
.CurrentDomain
);
36 app
.DoCallBack (Driver
.OtherDomain
);
39 AppDomain
.Unload (app
);