protected virtual void Dispose(bool disposing) { if (!this.hasDisposed) { if (disposing) { if (this.IsObserverRunning) { this.StopObservers(); } if (this.globalShutdownEventHandle != null) { this.globalShutdownEventHandle.Dispose(); } if (this.observers?.Count > 0) { foreach (var obs in this.observers) { obs?.Dispose(); } this.observers.Clear(); } if (FabricClientInstance != null) { FabricClientInstance.Dispose(); FabricClientInstance = null; } if (this.cts != null) { this.cts.Dispose(); this.cts = null; } // Flush and Dispose all NLog targets. No more logging. Logger.Flush(); DataTableFileLogger.Flush(); Logger.ShutDown(); DataTableFileLogger.ShutDown(); this.hasDisposed = true; } } }
private bool disposedValue; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!this.disposedValue) { if (disposing) { if (FabricClientInstance != null) { FabricClientInstance.Dispose(); FabricClientInstance = null; } } this.disposedValue = true; } }