Example #1
0
 public delegate void FuncOR <T1, T2>(out T1 arg1, ref T2 arg2);    public static void LockedCall <T1, T2>(string name, FuncOR <T1, T2> func, out T1 arg1, ref T2 arg2)
 {
     while (true)
     {
         try { var mutex = new Mutex(false, name); mutex.WaitOne();            func(out arg1, ref arg2); mutex.ReleaseMutex(); } catch (AbandonedMutexException) { }
     }
 }
Example #2
0
 public delegate U    FuncOR <T1, T2, U>(out T1 arg1, ref T2 arg2);    public static U    LockedCall <T1, T2, U>(string name, FuncOR <T1, T2, U> func, out T1 arg1, ref T2 arg2)
 {
     while (true)
     {
         try { var mutex = new Mutex(false, name); mutex.WaitOne(); U result = func(out arg1, ref arg2); mutex.ReleaseMutex(); return(result); } catch (AbandonedMutexException) { }
     }
 }