private async void OnConnectionChanged(object sender, bool connected) { if (connected) { return; } // to make things simpler, this is not cancellable. I believe this // is okay since this handle rare cases where remote host is recycled or // removed using (await _gate.DisposableWaitAsync(CancellationToken.None).ConfigureAwait(false)) { _client.ConnectionChanged -= OnConnectionChanged; _sessionDoNotAccessDirectly?.Dispose(); _sessionDoNotAccessDirectly = null; _client = await _workspace.TryGetRemoteHostClientAsync(CancellationToken.None).ConfigureAwait(false); if (_client != null) { // client can be null if host is shutting down _client.ConnectionChanged += OnConnectionChanged; } } }
public void Dispose() { _inner.Dispose(); }