コード例 #1
0
        public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state)
        {
            Fx.Assert(callback != null, "must have a non-null call back for async purposes");

            AsyncWaitHandle waiter = null;

            lock (this.ThisLock)
            {
                if (this.aborted)
                {
                    throw Fx.Exception.AsError(CreateObjectAbortedException());
                }

                if (this.count < this.maxCount)
                {
                    this.count++;
                    return(true);
                }

                waiter = new AsyncWaitHandle();
                this.Waiters.Enqueue(waiter);
            }

            return(waiter.WaitAsync(EnteredAsyncCallback, new EnterAsyncData(this, waiter, callback, state), timeout));
        }
コード例 #2
0
        public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state)
        {
            bool flag;

            lock (this.ThisLock)
            {
                if (!this.aborted)
                {
                    if (this.count >= this.maxCount)
                    {
                        AsyncWaitHandle asyncWaitHandle = new AsyncWaitHandle();
                        this.Waiters.Enqueue(asyncWaitHandle);
                        return(asyncWaitHandle.WaitAsync(ThreadNeutralSemaphore.EnteredAsyncCallback, new ThreadNeutralSemaphore.EnterAsyncData(this, asyncWaitHandle, callback, state), timeout));
                    }
                    else
                    {
                        ThreadNeutralSemaphore threadNeutralSemaphore = this;
                        threadNeutralSemaphore.count = threadNeutralSemaphore.count + 1;
                        flag = true;
                    }
                }
                else
                {
                    throw Fx.Exception.AsError(this.CreateObjectAbortedException());
                }
            }
            return(flag);
        }
コード例 #3
0
        public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state)
        {
            AsyncWaitHandle item = null;

            lock (this.ThisLock)
            {
                if (this.aborted)
                {
                    throw Fx.Exception.AsError(this.CreateObjectAbortedException());
                }
                if (this.count < this.maxCount)
                {
                    this.count++;
                    return(true);
                }
                item = new AsyncWaitHandle();
                this.Waiters.Enqueue(item);
            }
            return(item.WaitAsync(EnteredAsyncCallback, new EnterAsyncData(this, item, callback, state), timeout));
        }
 public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state)
 {
     AsyncWaitHandle item = null;
     lock (this.ThisLock)
     {
         if (this.aborted)
         {
             throw Fx.Exception.AsError(this.CreateObjectAbortedException());
         }
         if (this.count < this.maxCount)
         {
             this.count++;
             return true;
         }
         item = new AsyncWaitHandle();
         this.Waiters.Enqueue(item);
     }
     return item.WaitAsync(EnteredAsyncCallback, new EnterAsyncData(this, item, callback, state), timeout);
 }
コード例 #5
0
        public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state)
        {
            Fx.Assert(callback != null, "must have a non-null call back for async purposes");

            AsyncWaitHandle waiter = null;

            lock (this.ThisLock)
            {
                if (this.aborted)
                {
                    throw Fx.Exception.AsError(CreateObjectAbortedException());
                }

                if (this.count < this.maxCount)
                {
                    this.count++;
                    return true;
                }

                waiter = new AsyncWaitHandle();
                this.Waiters.Enqueue(waiter);
            }

            return waiter.WaitAsync(EnteredAsyncCallback, new EnterAsyncData(this, waiter, callback, state), timeout);
        }
コード例 #6
0
		public bool EnterAsync(TimeSpan timeout, FastAsyncCallback callback, object state)
		{
			bool flag;
			lock (this.ThisLock)
			{
				if (!this.aborted)
				{
					if (this.count >= this.maxCount)
					{
						AsyncWaitHandle asyncWaitHandle = new AsyncWaitHandle();
						this.Waiters.Enqueue(asyncWaitHandle);
						return asyncWaitHandle.WaitAsync(ThreadNeutralSemaphore.EnteredAsyncCallback, new ThreadNeutralSemaphore.EnterAsyncData(this, asyncWaitHandle, callback, state), timeout);
					}
					else
					{
						ThreadNeutralSemaphore threadNeutralSemaphore = this;
						threadNeutralSemaphore.count = threadNeutralSemaphore.count + 1;
						flag = true;
					}
				}
				else
				{
					throw Fx.Exception.AsError(this.CreateObjectAbortedException());
				}
			}
			return flag;
		}
 public BindReclaimedLockAsyncResult(InstancePersistenceContext context, AsyncWaitHandle wait, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.context = context;
     if (wait.WaitAsync(waitComplete, this, timeout))
     {
         this.context.ConcludeBindReclaimedLockHelper();
         base.Complete(true);
     }
 }