2 // shared-generic-synchronized.2.cs:
4 // Tests for the 'synchronized' method attribute in shared generic methods
8 using System.Threading;
9 using System.Runtime.CompilerServices;
11 public class Test<T> {
13 [MethodImplAttribute(MethodImplOptions.Synchronized)]
20 [MethodImplAttribute(MethodImplOptions.Synchronized)]
21 public static int test_static () {
22 Monitor.Exit (typeof (Test<T>));
23 Monitor.Enter (typeof (Test<T>));
27 [MethodImplAttribute(MethodImplOptions.Synchronized)]
28 public int test_exception () {
30 throw new Exception ("A");
33 [MethodImplAttribute(MethodImplOptions.Synchronized)]
34 public virtual int test_virtual () {
42 public delegate int Delegate1 ();
44 static public int Main (String[] args) {
45 Test<string> b = new Test<string> ();
48 Console.WriteLine ("Test1...");
50 Console.WriteLine ("Test2...");
51 Test<string>.test_static ();
52 Console.WriteLine ("Test3...");
56 catch (SynchronizationLockException ex) {
59 catch (Exception ex) {
60 // The other exception should be overwritten by the lock one
64 Console.WriteLine ("Test4...");
67 Console.WriteLine ("Test5...");
68 Delegate1 d = new Delegate1 (b.test);
71 Console.WriteLine ("Test6...");
72 d = new Delegate1 (Test<string>.test_static);
75 Console.WriteLine ("Test7...");
76 d = new Delegate1 (b.test_virtual);
79 Console.WriteLine ("Test8...");
80 d = new Delegate1 (b.test_exception);
84 catch (SynchronizationLockException ex) {
87 catch (Exception ex) {