2 using System.Collections.Generic;
3 using System.Reflection;
4 using System.Runtime.InteropServices;
5 using System.Threading;
10 TestDriver.RunTests (typeof (Tests));
13 // Check that try-catch clauses are not enlarged to encompass a Monitor.Enter
14 public static int test_0_enter_catch_clause () {
19 } catch (Exception ex) {
22 } catch (Exception ex) {
28 const int thread_count = 3;
31 public static int test_0_enter_abort_race () {
32 AppDomain ad = AppDomain.CreateDomain ("foo");
33 Thread t = new Thread (StartAppDomain);
35 Thread.Sleep (thread_count * 100 * 2);
36 // This will abort the threads created by StartAppDomain
37 AppDomain.Unload (ad);
41 static void StartAppDomain (object dummy)
43 ((AppDomain) dummy).DoCallBack (Main2);
48 Thread[] t = new Thread [thread_count];
49 for (int i = 0; i < t.Length; i++) {
50 t[i] = new Thread (LockMe);
52 Thread.Sleep (100); // this is just so that gdb's [New Thread ...] message are properly coupled with our "Thread # entered" messages
54 Thread.Sleep ((int) (thread_count * 100 * 1.5));
57 static object the_lock = new object ();
59 static void LockMe (object thread_id)
61 bool unlocked = false;
63 Monitor.Enter (the_lock);
65 Thread.Sleep (thread_count * 1000);
68 Monitor.Exit (the_lock);
71 } catch (Exception ex) {