private void Dispose(bool disposing) { if (disposing) { if (_loadContext != null) { _loadContext.Unloading -= LoadContext_Unloading; _loadContext = null; } _traceManager?.Dispose(); _secretMasker?.Dispose(); _term?.Dispose(); _trace?.Dispose(); _agentShutdownTokenSource?.Dispose(); try { Directory.Delete(_tempDirectoryRoot); } catch (Exception) { // eat exception on dispose } } }