private void TerminateInternal() { // If we fail, we at least should advertise that we're now dead Interlocked.Exchange(ref _terminated, _true); EventsTerminated?.Invoke(this, EventArgs.Empty); EventsTerminated = delegate { }; var projectIds = _components.Keys.ToArray(); foreach (var projectid in projectIds) { UnregisterProjectHandlers(projectid); } if (_projects.IsWrappingNullReference) { return; } _projects.ProjectActivated -= ProjectActivatedHandler; _projects.ProjectRenamed -= ProjectRenamedHandler; _projects.ProjectRemoved -= ProjectRemovedHandler; _projects.ProjectAdded -= ProjectAddedHandler; _projects.DetachEvents(); _projects.Dispose(); }
public void Dispose() { if (_disposed) { return; } ExecuteWithinWriteLock(() => ClearCollections()); _disposed = true; _projectsCollection.Dispose(); _projectsCollection = null; _refreshProtectionLock.Dispose(); }
protected virtual void Dispose(bool disposing) { if (_disposed || !disposing) { return; } ExecuteWithinWriteLock(() => ClearCollections()); _disposed = true; _projectsCollection.Dispose(); _projectsCollection = null; _refreshProtectionLock.Dispose(); }
/// <remarks> /// This is a not a true implementation of IDisposable pattern /// because the method is made private and is available only /// via the static method <see cref="Terminate"/> to provide /// a single point of entry for disposing the singleton class /// </remarks> private void Dispose(bool disposing) { if (!_disposed && _projects != null) { EventsTerminated?.Invoke(this, EventArgs.Empty); var projectIds = _components.Keys.ToArray(); foreach (var projectid in projectIds) { UnregisterComponents(projectid); } _projects.ProjectActivated -= ProjectActivatedHandler; _projects.ProjectRenamed -= ProjectRenamedHandler; _projects.ProjectRemoved -= ProjectRemovedHandler; _projects.ProjectAdded -= ProjectAddedHandler; _projects.DetachEvents(); _projects.Dispose(); _disposed = true; } }