public static async Task InitializeAsync(AsyncPackage package) { // Call to AddCommand in constructor requires UI thread await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); var dte = await package.GetServiceAsync(typeof(DTE)) as DTE; var commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as IMenuCommandService; Instance = new CopyCommand(package, dte, commandService); }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); await CopyCommand.InitializeAsync(this); }