protected override IEnumerator <IteratorAsyncResult <MessageBrowser.RetryBrowserAsyncResult> .AsyncStep> GetAsyncSteps() { TimeSpan timeSpan; bool flag; bool flag1; int num = 0; timeSpan = (this.browser.RetryPolicy.IsServerBusy ? Microsoft.ServiceBus.RetryPolicy.ServerBusyBaseSleepTime : TimeSpan.Zero); TimeSpan timeSpan1 = timeSpan; if (!this.browser.RetryPolicy.IsServerBusy || !(Microsoft.ServiceBus.RetryPolicy.ServerBusyBaseSleepTime >= base.OriginalTimeout)) { do { flag1 = false; if (timeSpan1 != TimeSpan.Zero) { yield return(base.CallAsyncSleep(timeSpan1)); } MessageBrowser.RetryBrowserAsyncResult retryBrowserAsyncResult = this; IteratorAsyncResult <MessageBrowser.RetryBrowserAsyncResult> .BeginCall beginCall = (MessageBrowser.RetryBrowserAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.browser.OnBeginPeek(thisPtr.trackingContext, thisPtr.fromSequenceNumber, thisPtr.messageCount, t, c, s); yield return(retryBrowserAsyncResult.CallAsync(beginCall, (MessageBrowser.RetryBrowserAsyncResult thisPtr, IAsyncResult r) => thisPtr.Messages = thisPtr.browser.OnEndPeek(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException == null) { this.browser.RetryPolicy.ResetServerBusy(); } else { MessagingPerformanceCounters.IncrementExceptionPerSec(this.browser.MessagingFactory.Address, 1, base.LastAsyncStepException); flag = (base.TransactionExists ? false : this.browser.RetryPolicy.ShouldRetry(base.RemainingTime(), num, base.LastAsyncStepException, out timeSpan1)); flag1 = flag; if (!flag1) { continue; } MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteRetryPolicyIteration(this.trackingContext.Activity, this.trackingContext.TrackingId, this.browser.RetryPolicy.GetType().Name, "Peek", num, timeSpan1.ToString(), this.LastAsyncStepException.GetType().FullName, this.LastAsyncStepException.Message)); num++; } }while (flag1); base.Complete(base.LastAsyncStepException); } else { string str = this.browser.RetryPolicy.ServerBusyExceptionMessage; yield return(base.CallAsyncSleep(base.RemainingTime())); base.Complete(new ServerBusyException(str, this.trackingContext)); } }
protected override IEnumerator <IteratorAsyncResult <MessageSession.RetrySessionAsyncResult> .AsyncStep> GetAsyncSteps() { TimeSpan timeSpan; bool flag; bool flag1; int num = 0; timeSpan = (this.session.RetryPolicy.IsServerBusy ? Microsoft.ServiceBus.RetryPolicy.ServerBusyBaseSleepTime : TimeSpan.Zero); TimeSpan zero = timeSpan; if (!this.session.RetryPolicy.IsServerBusy || !(Microsoft.ServiceBus.RetryPolicy.ServerBusyBaseSleepTime >= base.OriginalTimeout)) { do { flag1 = false; if (zero != TimeSpan.Zero) { yield return(base.CallAsyncSleep(zero)); } switch (this.operation) { case MessageSession.SessionOperation.GetState: { MessageSession.RetrySessionAsyncResult retrySessionAsyncResult = this; Transaction ambientTransaction = base.AmbientTransaction; IteratorAsyncResult <MessageSession.RetrySessionAsyncResult> .BeginCall beginCall = (MessageSession.RetrySessionAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.session.OnBeginGetState(thisPtr.trackingContext, t, c, s); yield return(retrySessionAsyncResult.CallTransactionalAsync(ambientTransaction, beginCall, (MessageSession.RetrySessionAsyncResult thisPtr, IAsyncResult r) => thisPtr.SessionState = thisPtr.session.OnEndGetState(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); break; } case MessageSession.SessionOperation.SetState: { if (this.stream != null && this.stream.CanSeek && this.stream.Position != (long)0) { this.stream.Position = (long)0; } MessageSession.RetrySessionAsyncResult retrySessionAsyncResult1 = this; Transaction transaction = base.AmbientTransaction; IteratorAsyncResult <MessageSession.RetrySessionAsyncResult> .BeginCall beginCall1 = (MessageSession.RetrySessionAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.session.OnBeginSetState(thisPtr.trackingContext, thisPtr.stream, t, c, s); yield return(retrySessionAsyncResult1.CallTransactionalAsync(transaction, beginCall1, (MessageSession.RetrySessionAsyncResult thisPtr, IAsyncResult r) => thisPtr.session.OnEndSetState(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); break; } case MessageSession.SessionOperation.RenewSessionLock: { MessageSession.RetrySessionAsyncResult retrySessionAsyncResult2 = this; IteratorAsyncResult <MessageSession.RetrySessionAsyncResult> .BeginCall beginCall2 = (MessageSession.RetrySessionAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.session.OnBeginRenewLock(thisPtr.trackingContext, t, c, s); yield return(retrySessionAsyncResult2.CallAsync(beginCall2, (MessageSession.RetrySessionAsyncResult thisPtr, IAsyncResult r) => thisPtr.LockedUntilUtcTime = thisPtr.session.OnEndRenewLock(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); break; } } if (base.LastAsyncStepException == null) { this.session.RetryPolicy.ResetServerBusy(); } else { base.LastAsyncStepException = this.session.ProcessException(base.LastAsyncStepException); MessagingPerformanceCounters.IncrementExceptionPerSec(this.session.MessagingFactory.Address, 1, base.LastAsyncStepException); flag = (base.TransactionExists ? false : this.session.RetryPolicy.ShouldRetry(base.RemainingTime(), num, base.LastAsyncStepException, out zero)); flag1 = flag; if (this.operation == MessageSession.SessionOperation.SetState && this.stream != null && !this.stream.CanSeek) { flag1 = false; zero = TimeSpan.Zero; MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteRetryPolicyStreamNotSeekable(this.trackingContext.Activity, this.trackingContext.TrackingId, this.session.RetryPolicy.GetType().Name, this.operation.ToString())); } if (!flag1) { continue; } MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteRetryPolicyIteration(this.trackingContext.Activity, this.trackingContext.TrackingId, this.session.RetryPolicy.GetType().Name, this.operation.ToString(), num, zero.ToString(), this.LastAsyncStepException.GetType().FullName, this.LastAsyncStepException.Message)); num++; } }while (flag1); base.Complete(base.LastAsyncStepException); } else { string str = this.session.RetryPolicy.ServerBusyExceptionMessage; yield return(base.CallAsyncSleep(base.RemainingTime())); base.Complete(new ServerBusyException(str, this.trackingContext)); } }