public async Task CloseAsync() { if (session != null) { session.Dispose(); session = null; } try { channel.Dispose(); } catch (Exception ex) { Console.WriteLine("Channel close exception {0}", ex.Message); Console.WriteLine("Channel close exception stack trace {0}", ex.StackTrace); } await Task.CompletedTask; }
protected void Disposing(bool disposing) { if (!disposed) { if (disposing) { try { if (adapter != null) { adapter.Dispose(); logger?.LogDebugAsync($"MQTT adapter disposed on channel {Channel.Id}").GetAwaiter(); } } catch (Exception ex) { logger?.LogErrorAsync(ex, $"MQTT adapter disposing orleans adapter error on channel '{Channel.Id}'.").GetAwaiter(); } try { if (Channel != null) { string channelId = Channel.Id; Channel.Dispose(); logger?.LogDebugAsync($"MQTT adapter channel {channelId} disposed").GetAwaiter(); } } catch (Exception ex) { logger?.LogErrorAsync(ex, $"MQTT adapter Disposing channel on channel '{Channel.Id}'.") .GetAwaiter(); } try { if (session != null) { session.Dispose(); logger?.LogDebugAsync("MQTT adapter disposed session."); } } catch (Exception ex) { logger?.LogErrorAsync(ex, $"MQTT adapter Disposing session on channel '{Channel.Id}'.") .GetAwaiter(); } } disposed = true; } }
protected void Disposing(bool disposing) { if (!disposed) { Trace.TraceInformation("MQTT Protocol Adapter disposing on Channel '{0}'.", Channel.Id); if (disposing) { try { if (adapter != null) { adapter.Dispose(); } } catch (Exception ex) { logger.LogError(ex, $"MQTT adapter Disposing orleans adapter error on channel '{Channel.Id}'."); } try { if (Channel != null) { Channel.Dispose(); } } catch (Exception ex) { logger.LogError(ex, $"MQTT adapter Disposing channel on channel '{Channel.Id}'."); } try { if (session != null) { session.Dispose(); } } catch (Exception ex) { logger.LogError(ex, $"MQTT adapter Disposing session on channel '{Channel.Id}'."); } } disposed = true; } }