private void AdviseBuildEvents() { Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.RunAsync(async() => { UpdateSolutionEventsListener solutionEventsListener = this; await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); solutionEventsListener._buildCommandIntercepter = BuildCommandIntercepter.InitializeCommandInterceptor(solutionEventsListener._serviceProvider); solutionEventsListener._buildCommandIntercepter.UserInitiatedBuild += solutionEventsListener.OnUserInitiatedBuild; }); }
private void UnadviseBuildEvents() { Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.RunAsync(async() => { UpdateSolutionEventsListener solutionEventsListener = this; await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (solutionEventsListener._buildCommandIntercepter == null) { return; } solutionEventsListener._buildCommandIntercepter.UserInitiatedBuild -= solutionEventsListener.OnUserInitiatedBuild; solutionEventsListener._buildCommandIntercepter.Dispose(); solutionEventsListener._buildCommandIntercepter = null; }); }
public NotificationDisabler(UpdateSolutionEventsListener listener) { _listener = listener ?? throw new ArgumentNullException(nameof(listener)); _listener._eventsEnabled = false; }