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 desctructor");
15 GetIntDelegate del = new GetIntDelegate (getInt);
16 AsyncCallback ac = new AsyncCallback (async_callback);
17 del.BeginInvoke (ac, "bla");
20 public int getInt () {
21 Console.WriteLine ("getInt in " + AppDomain.CurrentDomain);
27 public static int Main (string [] args) {
28 AppDomain domain = AppDomain.CreateDomain ("newdomain");
31 for (i = 0; i < 200; ++i) {
32 domain.CreateInstanceAndUnwrap (typeof (Test).Assembly.FullName, typeof (Test).FullName);
35 Console.WriteLine ("unloading");
36 AppDomain.Unload (domain);
37 Console.WriteLine ("unloaded");
40 GC.WaitForPendingFinalizers ();
42 Console.WriteLine ("done");