コード例 #1
0
ファイル: RequestClient.cs プロジェクト: alethic/MassTransit
        async Task <Response <T> > GetResponseInternal <T>(ClientRequestHandle <TRequest> .SendRequestCallback request,
                                                           CancellationToken cancellationToken, RequestTimeout timeout, RequestPipeConfiguratorCallback <TRequest> callback = null)
            where T : class
        {
            using RequestHandle <TRequest> handle = new ClientRequestHandle <TRequest>(_context, request, cancellationToken, timeout.Or(_timeout));

            callback?.Invoke(handle);

            return(await handle.GetResponse <T>().ConfigureAwait(false));
        }
コード例 #2
0
ファイル: RequestClient.cs プロジェクト: alethic/MassTransit
        async Task <Response <T1, T2> > GetResponseInternal <T1, T2>(ClientRequestHandle <TRequest> .SendRequestCallback request, CancellationToken cancellationToken,
                                                                     RequestTimeout timeout, RequestPipeConfiguratorCallback <TRequest> callback = null)
            where T1 : class
            where T2 : class
        {
            using RequestHandle <TRequest> handle = new ClientRequestHandle <TRequest>(_context, request, cancellationToken, timeout.Or(_timeout));

            callback?.Invoke(handle);

            Task <Response <T1> > result1 = handle.GetResponse <T1>(false);
            Task <Response <T2> > result2 = handle.GetResponse <T2>();

            var task = await Task.WhenAny(result1, result2).ConfigureAwait(false);

            await task.ConfigureAwait(false);

            return(new Response <T1, T2>(result1, result2));
        }