示例#1
0
        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);
            }
        }
示例#2
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);
            }
        }