public AsyncEntryBlockUC Enter()
 {
     using (SpinLock.Enter())
     {
         if (LockStatus == Status.Opened)
         {
             LockStatus = Status.Locked;
             return(new AsyncEntryBlockUC(ExclusiveEntry));
         }
         AccessItem access;
         Queue.Enqueue(access = AccessItem.NewTCS());
         return(new AsyncEntryBlockUC(null, access.TCS));
     }
 }
Example #2
0
        public EntryBlockUC Enter()
        {
            AccessItem access;

            using (SpinLock.Enter())
            {
                if (LockStatus == Status.Opened)
                {
                    LockStatus = Status.Locked;
                    return(ExclusiveEntry);
                }
                Queue.Enqueue(access = AccessItem.NewTCS());
            }
            return(access.WaitForResult());           //waiting synchronously for completion
        }