// Encapsulates taking the receivePumpLock, checking this.receiveHandler for null,
        // calls this.receiveHandler.ProcessErrorAsync (starting this operation inside the receivePumpLock).
        private Task ReceiveHandlerProcessEventsAsync(IEnumerable <EventData> eventDatas)
        {
            Task processEventsTask = null;

            lock (receivePumpLock)
            {
                if (receiveHandler != null)
                {
                    processEventsTask = receiveHandler.ProcessEventsAsync(eventDatas);
                }
            }

            return(processEventsTask ?? Task.FromResult(0));
        }
 private async void GenerateMessages()
 {
     while ((!this.token.IsCancellationRequested) && (this.outerHandler != null))
     {
         EventProcessorEventSource.Current.Message("MOCK Generating messages and sending to handler");
         IEnumerable <EventData>  events          = ReceiveAsync(10, TimeSpan.FromSeconds(10.0)).Result; // TODO get count from somewhere real
         IPartitionReceiveHandler capturedHandler = this.outerHandler;
         if (capturedHandler != null)
         {
             await capturedHandler.ProcessEventsAsync(events);
         }
     }
     EventProcessorEventSource.Current.Message("MOCK Message generation ending");
 }
예제 #3
0
 private void Dispatch(EventData eventData, IPartitionReceiveHandler processor)
 {
     processor.ProcessEventsAsync(new[] { eventData }).GetAwaiter().GetResult();
 }