Beispiel #1
0
        //List<InstancePersistenceEvent> StartWaiting(WaitForEventsAsyncResult result, IOThreadTimer timeoutTimer, TimeSpan timeout)
        private List <InstancePersistenceEvent> StartWaiting(WaitForEventsAsyncResult result, DelayTimer timeoutTimer, TimeSpan timeout)
        {
            lock (ThisLock)
            {
                if (_waitResult != null)
                {
                    throw Fx.Exception.AsError(new InvalidOperationException(SR.WaitAlreadyInProgress));
                }
                if (!IsValid)
                {
                    throw Fx.Exception.AsError(new OperationCanceledException(SR.HandleFreed));
                }

                if (_boundOwnerEvents != null && _boundOwnerEvents.Count > 0)
                {
                    Fx.Assert(Owner != null, "How do we have owner events without an owner.");
                    List <InstancePersistenceEvent> readyEvents = Store.SelectSignaledEvents(_boundOwnerEvents, Owner);
                    if (readyEvents != null)
                    {
                        Fx.Assert(readyEvents.Count != 0, "Should not return a zero-length list.");
                        return(readyEvents);
                    }
                }

                _waitResult = result;

                // This is done here to be under the lock.  That way it doesn't get canceled before it is set.
                if (timeoutTimer != null)
                {
                    timeoutTimer.Set(timeout);
                }

                return(null);
            }
        }