/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static async Task InitializeAsync(AsyncPackage package) { // Switch to the main thread - the call to AddCommand in FormatCommand's constructor requires // the UI thread. await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); OleMenuCommandService commandService = await package.GetServiceAsync((typeof(IMenuCommandService))) as OleMenuCommandService; Instance = new FormatCommand(package, commandService); }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); await FormatCommand.InitializeAsync(this); //Read settings SettingsManager settingsManager = new ShellSettingsManager(this as System.IServiceProvider); userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); //Load settings on init LoadSettings(); //Save settings on close ((OptionPageGrid)GetDialogPage(typeof(OptionPageGrid))).onClose = SaveSettings; //Load settings on open ((OptionPageGrid)GetDialogPage(typeof(OptionPageGrid))).onOpen = LoadSettings; }