public ServiceTesterToken GetToken() { lock (syncRoot) { nonexclusive.WaitOne(); var token = new ServiceTesterToken(this, false); tokens.Add(token); exclusive.Reset(); return(token); } }
public ServiceTesterToken GetExclusiveToken() { lock (syncRoot) { exclusive.WaitOne(); var token = new ServiceTesterToken(this, true); tokens.Add(token); exclusive.Reset(); nonexclusive.Reset(); return token; } }
public void ReleaseToken(ServiceTesterToken token) { lock (syncRoot) { tokens.Remove(token); if (token.IsExclusive) { exclusive.Set(); nonexclusive.Set(); } else if (tokens.Count == 0) { exclusive.Set(); } } }