src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Tree/Dependencies/Snapshot/AggregateDependenciesSnapshotProvider.cs
/// <summary>
/// When a given project context is unloaded, remove it form the cache and unregister event handlers
/// </summary>
When a given project context is unloaded, remove it form the cache and unregister event handlers
When a given project context is unloaded remove it form the cache and unregister event handlers
internal void OnSnapshotProviderUnloading(object sender, SnapshotProviderUnloadingEventArgs e)
        {
            var snapshotProvider = e.SnapshotProvider;
            if (snapshotProvider == null)
            {
                return;
            }
            SnapshotProviderUnloading?.Invoke(this, e);
            lock(_snapshotProvidersLock)
            {
                SnapshotProviders.TryRemove(snapshotProvider.ProjectFilePath, out IDependenciesSnapshotProvider provider);
                snapshotProvider.SnapshotRenamed -= OnSnapshotRenamed;
                snapshotProvider.SnapshotChanged -= OnSnapshotChanged;
                snapshotProvider.SnapshotProviderUnloading -= OnSnapshotProviderUnloading;
            }
        }
internal void OnSnapshotProviderUnloading ( object sender , SnapshotProviderUnloadingEventArgs e ) { var snapshotProvider = e . SnapshotProvider ; if ( snapshotProvider == null ) { return ; } SnapshotProviderUnloading ? . Invoke ( this , e ) ; lock ( _snapshotProvidersLock ) { SnapshotProviders . TryRemove ( snapshotProvider . ProjectFilePath , out IDependenciesSnapshotProvider provider ) ; snapshotProvider . SnapshotRenamed -= OnSnapshotRenamed ; snapshotProvider . SnapshotChanged -= OnSnapshotChanged ; snapshotProvider . SnapshotProviderUnloading -= OnSnapshotProviderUnloading ; } }
When a given project context is unloaded, remove it form the cache and unregister event handlers
When a given project context is unloaded remove it form the cache and unregister event handlers
sender
object
e
SnapshotProviderUnloadingEventArgs