Ejemplo n.º 1
0
        public Task CompleteWorkAsync(IChannelHandlerContext context, TWorkId workId)
        {
            if (this.incompleteQueue.Count == 0)
            {
                throw new IotHubClientException("Nothing to complete.");
            }
            IncompleteWorkItem incompleteWorkItem = this.incompleteQueue.Peek();

            if (incompleteWorkItem.Id.Equals(workId))
            {
                this.incompleteQueue.Dequeue();
                return(this.completeWork(context, incompleteWorkItem.WorkItem));
            }
            throw new IotHubClientException($"Work must be complete in the same order as it was started. Expected work id: '{incompleteWorkItem.Id}', actual work id: '{workId}'");
        }
        public Task CompleteWorkAsync(IChannelHandlerContext context, TWorkId workId)
        {
            if (!_incompleteQueue.Any())
            {
                throw new IotHubException("Nothing to complete.", isTransient: false);
            }

            IncompleteWorkItem incompleteWorkItem = _incompleteQueue.Peek();

            if (incompleteWorkItem.Id.Equals(workId))
            {
                _incompleteQueue.Dequeue();
                return(_completeWorkAsync(context, incompleteWorkItem.WorkItem));
            }

            throw new IotHubException(
                      $"Work must be complete in the same order as it was started. Expected work id: '{incompleteWorkItem.Id}', actual work id: '{workId}'",
                      isTransient: false);
        }