コード例 #1
0
        private static void OnPeekCompleted(IAsyncResult result)
        {
            Msmq4PoisonHandler asyncState = result.AsyncState as Msmq4PoisonHandler;

            MsmqQueue.ReceiveResult unknown = MsmqQueue.ReceiveResult.Unknown;
            try
            {
                unknown = asyncState.retryQueueForPeek.EndPeek(result);
            }
            catch (MsmqException exception)
            {
                MsmqDiagnostics.ExpectedException(exception);
            }
            if (MsmqQueue.ReceiveResult.MessageReceived == unknown)
            {
                lock (asyncState)
                {
                    if (!asyncState.disposed)
                    {
                        TimeSpan timeFromNow = (TimeSpan)((MsmqDateTime.ToDateTime(asyncState.retryQueueMessage.LastMoveTime.Value) + asyncState.ReceiveParameters.RetryCycleDelay) - DateTime.UtcNow);
                        if (timeFromNow < TimeSpan.Zero)
                        {
                            asyncState.OnTimer(asyncState);
                        }
                        else
                        {
                            asyncState.timer.Set(timeFromNow);
                        }
                    }
                }
            }
        }
コード例 #2
0
        static void StartPeek(object state)
        {
            Msmq4PoisonHandler handler = state as Msmq4PoisonHandler;

            lock (handler)
            {
                if (!handler.disposed)
                {
                    handler.retryQueueForPeek.BeginPeek(handler.retryQueueMessage, TimeSpan.MaxValue, onPeekCompleted, handler);
                }
            }
        }
コード例 #3
0
        static void OnPeekCompleted(IAsyncResult result)
        {
            Msmq4PoisonHandler handler = result.AsyncState as Msmq4PoisonHandler;

            MsmqQueue.ReceiveResult receiveResult = MsmqQueue.ReceiveResult.Unknown;
            try
            {
                receiveResult = handler.retryQueueForPeek.EndPeek(result);
            }
            catch (MsmqException ex)
            {
                MsmqDiagnostics.ExpectedException(ex);
            }

            if (MsmqQueue.ReceiveResult.MessageReceived == receiveResult)
            {
                lock (handler)
                {
                    if (!handler.disposed)
                    {
                        // Check the time - move it, and begin peeking again
                        // if necessary, or wait for the timeout.

                        DateTime lastMoveTime = MsmqDateTime.ToDateTime(handler.retryQueueMessage.LastMoveTime.Value);

                        TimeSpan waitTime = lastMoveTime + handler.ReceiveParameters.RetryCycleDelay - DateTime.UtcNow;
                        if (waitTime < TimeSpan.Zero)
                        {
                            handler.OnTimer(handler);
                        }
                        else
                        {
                            handler.timer.Set(waitTime);
                        }
                    }
                }
            }
        }