public void Subscibe(CallMessage call, SubscribeResult handler) { lock (this) call.Id = lastId++; sendToServer(call.ToString()); var tcs = new TaskCompletionSource <ResultMessage>(); lock (this) subscribes[call.Id] = handler; }
public Task <ResultMessage> Call(CallMessage call) { lock (this) call.Id = lastId++; sendToServer(call.ToString()); var tcs = new TaskCompletionSource <ResultMessage>(); lock (this) callers[call.Id] = tcs; return(tcs.Task); }