private static void OnCompleteMessageCompletion(IAsyncResult result) { MessageReceivePump.BatchCompleteAsyncResult batchCompleteAsyncResult = (MessageReceivePump.BatchCompleteAsyncResult)result; MessageReceivePump pump = batchCompleteAsyncResult.Pump; TrackingContext trackingContext = batchCompleteAsyncResult.TrackingContext; lock (pump.completionList) { try { try { AsyncResult <MessageReceivePump.BatchCompleteAsyncResult> .End(batchCompleteAsyncResult); } catch (Exception exception1) { Exception exception = exception1; MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.MessageReceivePumpFailedToComplete(trackingContext.Activity, trackingContext.TrackingId, trackingContext.SystemTracker, exception.ToStringSlim())); pump.RaiseExceptionReceivedEvent(exception, "Complete"); } } finally { pump.completionInProgress = false; } } pump.ScheduleMessageCompletion(null, trackingContext); }
private void ScheduleMessageCompletion(BrokeredMessage message, TrackingContext trackingContext) { MessageReceivePump.BatchCompleteAsyncResult batchCompleteAsyncResult = null; lock (this.completionList) { if (message != null) { this.completionList.Add(message.LockToken); } if (!this.completionInProgress && this.completionList.Count > 0) { this.completionInProgress = true; batchCompleteAsyncResult = new MessageReceivePump.BatchCompleteAsyncResult(this, trackingContext, MessageReceivePump.MessageCompletionOperationTimeout, new AsyncCallback(MessageReceivePump.OnCompleteMessageCompletion), null); } } if (batchCompleteAsyncResult != null) { IOThreadScheduler.ScheduleCallbackNoFlow((object o) => ((MessageReceivePump.BatchCompleteAsyncResult)o).Start(), batchCompleteAsyncResult); } }