2 using System.Threading;
3 using System.Runtime.Remoting;
5 public class Test : MarshalByRefObject {
6 delegate int GetIntDelegate ();
8 static void async_callback (IAsyncResult ar)
10 Console.WriteLine ("Async Callback in domain " + AppDomain.CurrentDomain + " " + ar.AsyncState);
14 Console.WriteLine ("in test destructor");
15 GetIntDelegate del = new GetIntDelegate (getInt);
16 AsyncCallback ac = new AsyncCallback (async_callback);
17 if (del.BeginInvoke (ac, "bla") == null) {
18 Console.WriteLine ("async result is null");
23 public int getInt () {
24 Console.WriteLine ("getInt in " + AppDomain.CurrentDomain);
30 public static int Main (string [] args) {
31 AppDomain domain = AppDomain.CreateDomain ("newdomain");
34 for (i = 0; i < 200; ++i) {
35 domain.CreateInstanceAndUnwrap (typeof (Test).Assembly.FullName, typeof (Test).FullName);
38 Console.WriteLine ("unloading");
39 AppDomain.Unload (domain);
40 Console.WriteLine ("unloaded");
43 GC.WaitForPendingFinalizers ();
45 Console.WriteLine ("done");