public bool Wait(int timeout)
        {
            var handles = this.Handles;
            ManualResetEventSlim handle = null;

            try
            {
                lock (this.SyncRoot)
                {
                    if (this.CompareState() == true)
                    {
                        return(true);
                    }

                    handle = new ManualResetEventSlim();
                    handles.Add(handle);
                }

                return(handle.WaitQuietly(timeout));
            }
            finally
            {
                handle.DisposeQuietly();

                lock (this.SyncRoot)
                {
                    handles.Remove(handle);
                }
            }
        }