private Task SendMessage(BaseRequest request) { return Task.Factory.StartNew(() => { _Client.Client.Send(request.BytesForWire()); }); }
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); }