protected override async Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { async Task InitializeDialControllerHostAsync() { void LoadOptions() { Options = (Options)GetDialogPage(typeof(Options)); CustomOptions = (CustomOptions)GetDialogPage(typeof(CustomOptions)); } try { var serviceProvider = await GetServiceAsync <SAsyncServiceProvider, IAsyncServiceProvider>(cancellationToken); var outputPane = await GetOutputPaneAsync(); LoadOptions(); var controllers = await serviceProvider.GetControllersAsync(cancellationToken); DialControllerHost = new DialControllerHost(outputPane, controllers); Options.OptionsApplied += DialControllerHost.OptionsApplied; } catch (Exception ex) { await ex.LogAsync("DialControllerHost.InitializeAsync"); } } KnownUIContexts.ShellInitializedContext.WhenActivated(() => ThreadHelper.JoinableTaskFactory.StartOnIdle(InitializeDialControllerHostAsync)); await base.InitializeAsync(cancellationToken, progress); }
protected override async Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { #pragma warning disable U2U1003 // Avoid declaring methods used in delegate constructors static void LoadOptions() { Options = (Options)GetDialogPage(typeof(Options)); CustomOptions = (CustomOptions)GetDialogPage(typeof(CustomOptions)); } #pragma warning restore U2U1003 // Avoid declaring methods used in delegate constructors static var optionsLoadTask = ThreadHelper.JoinableTaskFactory.StartOnIdle(LoadOptions); Logger.Initialize(await GetServiceAsync <SVsOutputWindow, IVsOutputWindow>(cancellationToken)); try { var serviceProvider = await GetServiceAsync <SAsyncServiceProvider, Microsoft.VisualStudio.Shell.IAsyncServiceProvider>(cancellationToken); await DialControllerHost.InitializeAsync(serviceProvider, optionsLoadTask, cancellationToken); Options.OptionsApplied += DialControllerHost.Instance.OptionsApplied; } catch (Exception ex) { Logger.Instance.Log(ex); } await base.InitializeAsync(cancellationToken, progress); }
public static async Task InitializeAsync(IAsyncServiceProvider provider, JoinableTask optionsLoadTask, CancellationToken cancellationToken) { var dte = await provider.GetDteAsync(cancellationToken); var compositionService = await provider.GetServiceAsync <SComponentModel, IComponentModel>(cancellationToken); Instance = new DialControllerHost(provider, dte, compositionService); var mainWindow = dte.DTE.MainWindow; await Task.WhenAll( ThreadHelper.JoinableTaskFactory.StartOnIdle(Instance.CreateStatusBarItem).JoinAsync(), ThreadHelper.JoinableTaskFactory.StartOnIdle(new Action(() => controllersMapping.Add(mainWindow, Instance.CreateController(mainWindow)))).JoinAsync()); await optionsLoadTask; await Instance.ImportProvidersAsync(cancellationToken); }