Пример #1
0
        private void SetCompletionResult(ResponseContents <TResponse> responseContents)
        {
            TimeoutAndCompletionSource completionSource;
            var requestId = responseContents.RequestId;

            if (completionSources.TryRemove(requestId, out completionSource))
            {
                completionSource.TaskCompletionSource.TrySetResult(responseContents.Response);
            }
            else
            {
                Trace.WriteLine("Error: ServiceClient received response that was not requested with the current client.");
            }
        }
        private async Task SubmitResponseAsync(RequestContents <TRequest> requestContents, TResponse response, CancellationToken cancellationToken)
        {
            var responseQueue = cloudQueueClient.GetQueueReference(requestContents.ResponseQueueName);

            var responseContents = new ResponseContents <TResponse>
            {
                RequestId = requestContents.RequestId,
                Response  = response
            };

            var responseJson = JsonConvert.SerializeObject(responseContents);

            var responseMessage = new CloudQueueMessage(responseJson);

            await responseQueue.AddMessageAsync(responseMessage, cancellationToken);
        }