public ServiceTesterToken GetToken()
        {
            lock (syncRoot)
            {
                nonexclusive.WaitOne();

                var token = new ServiceTesterToken(this, false);
                tokens.Add(token);

                exclusive.Reset();

                return(token);
            }
        }
Example #2
0
        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();
                }
            }
        }
Example #4
0
        public void ReleaseToken(ServiceTesterToken token)
        {
            lock (syncRoot)
            {
                tokens.Remove(token);

                if (token.IsExclusive)
                {
                    exclusive.Set();
                    nonexclusive.Set();
                }
                else if (tokens.Count == 0)
                {
                    exclusive.Set();
                }
            }
        }