private async Task DisposeSocketAsync(bool writeNotification = true) { try { if (socketClient != null) { await socketClient.DisposeAsync(); } } catch (Exception ex) { Logger.Log($"DisposeSocketAsync {ex.Message}", Prism.Logging.Category.Exception, Prism.Logging.Priority.High); if (writeNotification) { ViewModelContext.UiDispatcher.Invoke(() => { NotificationsAdd(new Message { MessageType = MessageType.Error, Text = $"Disconnect - {ex.Message}", TextVerbose = ex.ToString() }); }); } } finally { socketClient = null; IsConnected = false; } }
public async Task DisposeSocketAsync() { try { if (socketClient != null) { await socketClient.DisposeAsync(); } OnNotification(); } catch (Exception ex) { OnException(ex.Message, ex); } finally { socketClient = null; IsConnecting = false; IsConnected = false; } }
private async void OnDisconnect(object args) { await dipSocketClient.DisposeAsync(); }