public static async Task InitializeAsync(AsyncPackage package) { // Switch to the main thread - the call to AddCommand in DontCopyAlwaysCommand's constructor requires // the UI thread. await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); var commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; Instance = new DontCopyAlwaysCommand(package, commandService); }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); SolutionEvents.OnAfterOpenSolution += this.SolutionEvents_OnAfterOpenSolution; SolutionEvents.OnAfterLoadProject += this.SolutionEvents_OnAfterLoadProject; await DontCopyAlwaysCommand.InitializeAsync(this); await this.CheckAllProjectsInSolutionAsync(); }