public static async Task InitializeAsync(CollapseCommandPackage package) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; Instance = new CollapseCommand(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); await CollapseCommand.InitializeAsync(this); await ExpandCommand.InitializeAsync(this); var runningDocumentTable = new RunningDocumentTable(this); var dte = await this.GetServiceAsync(typeof(DTE)) as DTE2; MyRunningDocTableEvents.Instance.Initialize(this, runningDocumentTable, dte); runningDocumentTable.Advise(MyRunningDocTableEvents.Instance); }