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()}"); } }
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()}"); } }