* X11Structs.cs: Add a few ToString() overrides.
[mono.git] / mono / tests / appdomain-unload.cs
index f0a8967f4b50efd0d8f29bd0ac332951c9b84efb..4777b2b2bde154e6112dca3914b0036201319380 100644 (file)
@@ -1,5 +1,6 @@
 using System;
 using System.Threading;
+using System.Reflection;
 
 [Serializable]
 public class Foo {
@@ -82,6 +83,10 @@ public class UnloadThread {
        }
 }
 
+class CrossDomainTester : MarshalByRefObject
+{
+}
+
 public class Tests
 {
        public static int Main() {
@@ -91,6 +96,10 @@ public class Tests
        public static int test_0_unload () {
                for (int i = 0; i < 10; ++i) {
                        AppDomain appDomain = AppDomain.CreateDomain("Test-unload" + i);
+
+                       appDomain.CreateInstanceAndUnwrap (
+                               typeof (CrossDomainTester).Assembly.FullName, "CrossDomainTester");
+
                        AppDomain.Unload(appDomain);
                }
 
@@ -161,6 +170,30 @@ public class Tests
                return 1;
        }
 
+       static void Worker (object x) {
+               Thread.Sleep (100000);
+       }
+
+       public static void invoke_workers () {
+               for (int i = 0; i < 1; i ++)
+                       ThreadPool.QueueUserWorkItem (Worker);
+       }
+
+       public static int test_0_unload_with_threadpool () {
+               AppDomain domain = AppDomain.CreateDomain ("test_0_unload_with_threadpool");
+
+               domain.DoCallBack (new CrossAppDomainDelegate (invoke_workers));
+               AppDomain.Unload (domain);
+
+               return 0;
+       }
+
+       /*
+        * This test is not very deterministic since the thread which enqueues
+        * the work item might or might not be inside the domain when the unload
+        * happens. So disable this for now.
+        */
+       /*
        public static void DoUnload (object state) {
                AppDomain.Unload (AppDomain.CurrentDomain);
        }
@@ -178,6 +211,7 @@ public class Tests
 
                return 0;
        }
+       */
 
        public static void SyncCallback () {
                AppDomain.Unload (AppDomain.CurrentDomain);