0

I dont have much code to show since it is more about the fact that I did not find how to do this

I am launching a process in my VSIX that keeps running even after closing Visual Studio

I was wondering how to get notified when VS is closing so I could kill the process

[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[ProvideAutoLoad(UIContextGuids.SolutionExists, PackageAutoLoadFlags.BackgroundLoad)]
[ProvideAutoLoad(UIContextGuids.NoSolution, PackageAutoLoadFlags.BackgroundLoad)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[ProvideMenuResource("Menus.ctmenu", 1)]
public sealed class MyPackage : AsyncPackage
{
  protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
  {
    await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
    var dte = ((IServiceProvider)this).GetService(typeof(DTE)) as DTE;
    Assumes.Present(dte);

    // Link the Event when VS CLOSING   
    DTE2 m_applicationObject = dte as DTE2;
    m_packageDTEEvents = m_applicationObject.Events.DTEEvents;
    m_packageDTEEvents.OnBeginShutdown += new _dispDTEEvents_OnBeginShutdownEventHandler(HandleVisualStudioShutDown);
    WindowEvents PackageWindowEvents = (WindowEvents)m_applicationObject.Events.get_WindowEvents(null);
    PackageWindowEvents.WindowClosing += new _dispWindowEvents_WindowClosingEventHandler(PackageWindowEvents_WindowClosing);
    AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;

any help appreciated

0 Answers0