using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace Sync_Ueb02_Latch { class Latch : ISynch { private ManualResetEvent waitHandle = new(false); private static uint countAquired = 0; private static object syncLock = new(); public void Acquire() { lock (syncLock) { countAquired++; } this.waitHandle.WaitOne(); } public uint GetAmountOfAquires() { uint readCount = 0; lock(syncLock) { readCount = countAquired; } return readCount; } public void Release() { this.waitHandle.Set(); } } }