示例#1
0
 void RunLock(LockMechanism lm)
 {
     try
     {
         Console.WriteLine($"Running {lm.GetType().Name}");
         lm.Wait();
         Thread.Sleep(1000);
         lm.Release();
     }
     catch (Exception e)
     {
         Console.WriteLine($"Error in {nameof(RunLock)} using {lm.GetType().Name}: {e.ToString()}");
     }
 }
示例#2
0
        async Task RunLockAsync(LockMechanism lm)
        {
            try
            {
                Console.WriteLine($"Running {lm.GetType().Name}");
                lm.Wait();
                await Task.Delay(1000);

                lm.Release();
            }catch (Exception e)
            {
                Console.WriteLine($"Error in {nameof(RunLockAsync)} using {lm.GetType().Name}: {e.ToString()}");
            }
        }