public void ExecuteInSemaphore(SemaphoreOptions opts, Action a) { if (opts == null) { throw new ArgumentNullException("opts"); } if (a == null) { throw new ArgumentNullException("a"); } using (var l = new AutoSemaphore(this, opts)) { if (l.IsHeld) { a(); } } }