Example #1
0
        internal bool EnqueueRetry(LoadRetryAsyncResult loadRetryAsyncResult)
        {
            bool flag = false;

            if (this.storeLock.IsValid)
            {
                flag = this.LoadRetryHandler.Enqueue(loadRetryAsyncResult);
            }
            return(flag);
        }
Example #2
0
 protected internal override bool EndTryCommand(IAsyncResult result)
 {
     if (result is LoadRetryAsyncResult)
     {
         return(LoadRetryAsyncResult.End(result));
     }
     if (result is SqlWorkflowInstanceStoreAsyncResult)
     {
         return(SqlWorkflowInstanceStoreAsyncResult.End(result));
     }
     return(base.EndTryCommand(result));
 }
Example #3
0
        internal bool EnqueueRetry(LoadRetryAsyncResult loadRetryAsyncResult)
        {
            Fx.Assert(this.IsLockRetryEnabled(),
                      "EnqueueRetry() should not be invoked if retry algorithm is set to NoRetry");

            bool result = false;

            if (this.storeLock.IsValid)
            {
                result = this.LoadRetryHandler.Enqueue(loadRetryAsyncResult);
            }

            return(result);
        }
 public bool Enqueue(LoadRetryAsyncResult command)
 {
     bool flag = false;
     DateTime key = DateTime.UtcNow.Add(command.RetryTimeout);
     lock (this.syncLock)
     {
         flag = this.retryQueue.Enqueue(key, command);
     }
     if (flag)
     {
         this.retryThreadTimer.Set(command.RetryTimeout);
     }
     return true;
 }
        static void OnTryCommandCallback(IAsyncResult result)
        {
            LoadRetryAsyncResult tryCommandAsyncResult = (LoadRetryAsyncResult)(result.AsyncState);
            Exception            completeException     = null;
            bool completeFlag = true;

            try
            {
                tryCommandAsyncResult.CompleteTryCommand(result);
            }
            catch (InstanceLockedException instanceLockedException)
            {
                TimeSpan retryDelay = tryCommandAsyncResult.InstanceStore.GetNextRetryDelay(++tryCommandAsyncResult.retryCount);

                if (retryDelay < tryCommandAsyncResult.commandTimeout.RemainingTime())
                {
                    tryCommandAsyncResult.RetryTimeout = retryDelay;

                    if (tryCommandAsyncResult.InstanceStore.EnqueueRetry(tryCommandAsyncResult))
                    {
                        tryCommandAsyncResult.lastInstanceLockedException = instanceLockedException;
                        completeFlag = false;
                    }
                }
                else if (TD.LockRetryTimeoutIsEnabled())
                {
                    TD.LockRetryTimeout(tryCommandAsyncResult.InstancePersistenceContext.EventTraceActivity, tryCommandAsyncResult.commandTimeout.OriginalTimeout.ToString());
                }

                if (completeFlag)
                {
                    completeException = instanceLockedException;
                }
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                completeException = exception;
            }

            if (completeFlag)
            {
                tryCommandAsyncResult.Complete(false, completeException);
            }
        }
        public bool Enqueue(LoadRetryAsyncResult command)
        {
            bool     flag = false;
            DateTime key  = DateTime.UtcNow.Add(command.RetryTimeout);

            lock (this.syncLock)
            {
                flag = this.retryQueue.Enqueue(key, command);
            }
            if (flag)
            {
                this.retryThreadTimer.Set(command.RetryTimeout);
            }
            return(true);
        }
        public bool Enqueue(LoadRetryAsyncResult command)
        {
            bool     firstInQueue = false;
            DateTime retryTime    = DateTime.UtcNow.Add(command.RetryTimeout);

            lock (this.syncLock)
            {
                firstInQueue = this.retryQueue.Enqueue(retryTime, command);
            }

            if (firstInQueue)
            {
                this.retryThreadTimer.Set(command.RetryTimeout);
            }

            return(true);
        }
        public bool Enqueue(LoadRetryAsyncResult command)
        {
            bool firstInQueue = false;
            DateTime retryTime = DateTime.UtcNow.Add(command.RetryTimeout);

            lock (this.syncLock)
            {
                firstInQueue = this.retryQueue.Enqueue(retryTime, command);
            }

            if (firstInQueue)
            {
                this.retryThreadTimer.Set(command.RetryTimeout);
            }

            return true;
        }
Example #9
0
        private static void OnTryCommandCallback(IAsyncResult result)
        {
            LoadRetryAsyncResult asyncState = (LoadRetryAsyncResult)result.AsyncState;
            Exception            exception  = null;
            bool flag = true;

            try
            {
                asyncState.CompleteTryCommand(result);
            }
            catch (InstanceLockedException exception2)
            {
                TimeSpan nextRetryDelay = asyncState.InstanceStore.GetNextRetryDelay(++asyncState.retryCount);
                if (nextRetryDelay < asyncState.commandTimeout.RemainingTime())
                {
                    asyncState.RetryTimeout = nextRetryDelay;
                    if (asyncState.InstanceStore.EnqueueRetry(asyncState))
                    {
                        asyncState.lastInstanceLockedException = exception2;
                        flag = false;
                    }
                }
                else if (TD.LockRetryTimeoutIsEnabled())
                {
                    TD.LockRetryTimeout(asyncState.commandTimeout.OriginalTimeout.ToString());
                }
                if (flag)
                {
                    exception = exception2;
                }
            }
            catch (Exception exception3)
            {
                if (Fx.IsFatal(exception3))
                {
                    throw;
                }
                exception = exception3;
            }
            if (flag)
            {
                asyncState.Complete(false, exception);
            }
        }
        public void AbortPendingRetries()
        {
            this.retryThreadTimer.Cancel();

            ICollection <KeyValuePair <DateTime, LoadRetryAsyncResult> > result;

            lock (this.syncLock)
            {
                result = this.retryQueue.RemoveAll(x => x.Value != null);
            }

            foreach (KeyValuePair <DateTime, LoadRetryAsyncResult> value in result)
            {
                ActionItem.Schedule
                (
                    (data) =>
                {
                    LoadRetryAsyncResult tryCommandResult = data as LoadRetryAsyncResult;
                    tryCommandResult.AbortRetry();
                },
                    value.Value
                );
            }
        }
 internal bool EnqueueRetry(LoadRetryAsyncResult loadRetryAsyncResult)
 {
     bool flag = false;
     if (this.storeLock.IsValid)
     {
         flag = this.LoadRetryHandler.Enqueue(loadRetryAsyncResult);
     }
     return flag;
 }
Example #12
0
        public static bool End(IAsyncResult result)
        {
            LoadRetryAsyncResult thisPtr = AsyncResult.End <LoadRetryAsyncResult>(result);

            return(thisPtr.commandSuccess);
        }
        internal bool EnqueueRetry(LoadRetryAsyncResult loadRetryAsyncResult)
        {
            Fx.Assert(this.IsLockRetryEnabled(),
                "EnqueueRetry() should not be invoked if retry algorithm is set to NoRetry");

            bool result = false;

            if (this.storeLock.IsValid)
            {
                result = this.LoadRetryHandler.Enqueue(loadRetryAsyncResult);
            }

            return result;
        }