예제 #1
0
        public ServiceTesterToken GetToken()
        {
            lock (syncRoot)
            {
                nonexclusive.WaitOne();

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

                exclusive.Reset();

                return(token);
            }
        }
예제 #2
0
        public ServiceTesterToken GetExclusiveToken()
        {
            lock (syncRoot)
            {
                exclusive.WaitOne();

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

                exclusive.Reset();
                nonexclusive.Reset();

                return token;
            }
        }
예제 #3
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();
                }
            }
        }
예제 #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();
                }
            }
        }