public bool TryWaitResponse(Request req, out Response response, int wait = TIMEOUT) { Response result = null; var marker = new Task(() => { }); var action = new Action <Response>(r => { result = r; marker.RunSynchronously(); }); _handler.RegisterHandler((Response.ResponseOneofCase)req.RequestCase, action); AsyncSend(req); marker.Wait(wait); _handler.DeregisterHandler(action); response = result; return(response != null); }
public void DeregisterHandler(Action <Response> handler) => _handler.DeregisterHandler(handler);