public bool ProcessAndWait(NetworkMessage msg, EventHandler <MessageFromServerEventArgs> handler) { DataClient.OnMessageReceived += handler; try { PhaseLock.Reset(); DataClient.Send(msg); PhaseLock.Wait(GlobalTimeout.Token); return(!GlobalTimeout.IsCancellationRequested); } finally { DataClient.OnMessageReceived -= handler; } }
public void Dispose() { GlobalTimeout.Dispose(); PhaseLock?.Dispose(); }