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