Ejemplo n.º 1
0
		private Task OnReplyReceived(MessageDelivery delivery)
		{
			var correlationIndex = UInt32.Parse(delivery.properties.CorrelationId);
			var pos = correlationIndex % _maxConcurrentCalls;

			var taskLight = Interlocked.Exchange(ref _pendingCalls[pos], null);

			if (taskLight == null || taskLight.Id != correlationIndex)
			{
				// the helper was disposed and the task list was drained.
				if (_disposed) return Task.CompletedTask;
				
				// other situation, the call timeout'ed previously
			}
			else
			{
				taskLight.SetResult(delivery);
			}

			_semaphoreSlim.Release();

			return Task.CompletedTask;
		}
Ejemplo n.º 2
0
 public abstract Task Consume(MessageDelivery delivery);