示例#1
0
 private Task SendMessage(BaseRequest request)
 {
     return Task.Factory.StartNew(() =>
         {
             _Client.Client.Send(request.BytesForWire());
         });
 }
示例#2
0
        public async Task<BaseResponse> SendAndReturn(BaseRequest serverRequest)
        {
            serverRequest.CorrelationId = Interlocked.Increment(ref _LastRequestId);
            serverRequest.ClientId = "Unassigned";

            var networkRes = new TaskCompletionSource<byte[]>();
            _RequestCallbacks.TryAdd(serverRequest.CorrelationId, networkRes);
            await SendMessage(serverRequest);
            var res = await networkRes.Task;
            return serverRequest.ResponseDeserilaizer(res);
        }