public IVsTask Initialize(Microsoft.VisualStudio.Shell.Interop.IAsyncServiceProvider asyncServiceProvider, IProfferAsyncService pProfferService, IAsyncProgressCallback pProgressCallback) { return(ThreadHelper.JoinableTaskFactory.RunAsync <object>(async() => { BackgroundThreadInitialization(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); MainThreadInitialization(); return null; }).AsVsTask()); }
/// <summary> /// Performs the asynchronous initialization for the package in cases where IDE supports AsyncPackage. /// /// This method is always called from background thread initially. /// </summary> /// <param name="asyncServiceProvider">Async service provider instance to query services asynchronously</param> /// <param name="pProfferService">Async service proffer instance</param> /// <param name="IAsyncProgressCallback">Progress callback instance</param> /// <returns></returns> public IVsTask Initialize(Microsoft.VisualStudio.Shell.Interop.IAsyncServiceProvider asyncServiceProvider, IProfferAsyncService pProfferService, IAsyncProgressCallback pProgressCallback) { if (!isAsyncLoadSupported) { throw new InvalidOperationException("Async Initialize method should not be called when async load is not supported."); } return(ThreadHelper.JoinableTaskFactory.RunAsync <object>(async() => { BackgroundThreadInitialization(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); MainThreadInitialization(); return null; }).AsVsTask()); }
IVsTask IAsyncLoadablePackageInitialize.Initialize(IAsyncServiceProvider serviceProvider, IProfferAsyncService profferService, IAsyncProgressCallback progressCallback) { if (!_isAsyncLoadSupported) { throw new InvalidOperationException("Async Initialize method should not be called when async load is not supported."); } return(ThreadHelper.JoinableTaskFactory.RunAsync <object>(async() => { var componentModel = await serviceProvider.GetServiceAsync <IComponentModel>(typeof(SComponentModel)); _globalRunSettings = componentModel.GetService <IGlobalRunSettingsInternal2>(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); DoInitialize(); return null; }).AsVsTask()); }
public IVsTask Initialize(IAsyncServiceProvider pServiceProvider, IProfferAsyncService pProfferService, IAsyncProgressCallback pProgressCallback) { if (!_wakaTime.IsAsyncLoadSupported) { throw new InvalidOperationException("Async Initialize method should not be called when async load is not supported."); } return(ThreadHelper.JoinableTaskFactory.RunAsync <object>(async() => { _wakaTime.Logger.Debug("Initializing async."); InitializeAsync(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); OnOnStartupComplete(); return null; }).AsVsTask()); }
public IVsTask Initialize(IAsyncServiceProvider pServiceProvider, IProfferAsyncService pProfferService, IAsyncProgressCallback pProgressCallback) { if (!isAsyncLoadSupported) { throw new InvalidOperationException("Async Initialize method should not be called when async load is not supported."); } return(ThreadHelper.JoinableTaskFactory.RunAsync <object>(async() => { var dte = await pServiceProvider.GetServiceAsync <DTE>(typeof(DTE)); var runningDocumentTable = new RunningDocumentTable(this); var defaultConfig = (VisualStudioConfiguration)GetDialogPage(typeof(VisualStudioConfiguration)); var documentFormatService = new DocumentFormatService(dte, (doc) => new FormatDocumentConfiguration(doc, defaultConfig)); plugin = new FormatDocumentOnBeforeSave(dte, runningDocumentTable, documentFormatService); runningDocumentTable.Advise(plugin); return null; }).AsVsTask()); }
/// <summary> /// Performs the asynchronous initialization for the package in cases where IDE supports AsyncPackage. /// /// This method is always called from background thread initially. /// </summary> /// <param name="asyncServiceProvider">Async service provider instance to query services asynchronously</param> /// <param name="pProfferService">Async service proffer instance</param> /// <param name="IAsyncProgressCallback">Progress callback instance</param> /// <returns></returns> public IVsTask Initialize(Microsoft.VisualStudio.Shell.Interop.COMAsyncServiceProvider.IAsyncServiceProvider asyncServiceProvider, IProfferAsyncService pProfferService, IAsyncProgressCallback pProgressCallback) { if (!isAsyncLoadSupported) { throw new InvalidOperationException("Async Initialize method should not be called when async load is not supported."); } return(ThreadHelper.JoinableTaskFactory.RunAsync <object>(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); IVsUIShell shellService = await asyncServiceProvider.GetServiceAsync <IVsUIShell>(typeof(SVsUIShell)); this.MainThreadInitialization(shellService, isAsyncPath: true); return null; }).AsVsTask()); }
/// <summary> /// The async initialization in VS2015 and above. /// </summary> public IVsTask Initialize(IAsyncServiceProvider pServiceProvider, IProfferAsyncService pProfferService, IAsyncProgressCallback pProgressCallback) { return(ThreadHelper.JoinableTaskFactory.RunAsync <object>(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var shellService = await GetServiceAsync <IVsShell>(pServiceProvider, typeof(SVsShell)); var menuCommandService = await GetServiceAsync <IMenuCommandService>(pServiceProvider, typeof(IMenuCommandService)); DoInitialize(shellService, menuCommandService); return null; }).AsVsTask()); }
/// <summary> /// Performs the asynchronous initialization for the package in cases where IDE supports AsyncPackage. /// /// This method is always called from background thread initially. /// </summary> /// <param name="asyncServiceProvider">Async service provider instance to query services asynchronously</param> /// <param name="pProfferService">Async service proffer instance</param> /// <param name="IAsyncProgressCallback">Progress callback instance</param> /// <returns></returns> public IVsTask Initialize(IAsyncServiceProvider asyncServiceProvider, IProfferAsyncService pProfferService, IAsyncProgressCallback pProgressCallback) { if (!_isAsyncLoadSupported) { throw new InvalidOperationException("Async Initialize method should not be called when async load is not supported."); } return(ThreadHelper.JoinableTaskFactory.RunAsync <object>(async() => { BackgroundThreadInitialization(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var menuCommandService = (OleMenuCommandService)GetService(typeof(IMenuCommandService)); MainThreadInitialization(menuCommandService, isAsyncPath: true); return null; }).AsVsTask()); }