public async Task DisconnectAsync() { if (!IsConnected) { return; } try { Disconnecting?.Invoke(this, new ConnectionEventArgs($"Try to Disconnect\n{DateTime.UtcNow}\n{_hubConnection.ConnectionId}")); await _hubConnection.StopAsync(); if (IsConnected) { throw new InvalidOperationException("Disconnection faild"); } Disconnected?.Invoke(this, new ConnectionEventArgs($"Disconnected\n{DateTime.UtcNow}")); Debug.WriteLine($"Disconnection completed\n{DateTime.UtcNow}"); } catch (Exception ex) { Debug.WriteLine("Disconnection Failed: " + ex.Message); DisconnectionFailed?.Invoke(this, new ConnectionEventArgs("Disconnection Failed: " + ex.Message)); } }
public static bool IsDisconnectionFailed(Service service) { return(DisconnectionFailed.FirstOrDefault(s => s == service) != null); }