Exemplo n.º 1
0
        //
        // Tries to enter the write lock, activating the specified
        // cancellers.
        //

        public bool TryEnterWrite(StCancelArgs cargs) {
            int tid;
            if (FastTryEnterWrite(tid = Thread.CurrentThread.ManagedThreadId)) {
                return true;
            }

            //
            // We are not the current writer; so, try to enter the write
            // on the associated non-reentrant r/w lock.
            //

            if (rwlock.TryEnterWrite(cargs)) {
                writer = tid;
                count = 1;
                return true;
            }

            //
            // The specified timeout expired, so return failure.
            //

            return false;
        }