/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress); var objDte = await GetServiceAsync(typeof(DTE)); _dte = objDte as DTE; var metadata = new Metadata { EditorName = "visualstudio", PluginName = "visualstudio-wakatime", EditorVersion = _dte == null ? string.Empty : _dte.Version, PluginVersion = Constants.PluginVersion }; _logger = new Logger(Dependencies.GetConfigFilePath()); _wakatime = new Shared.ExtensionUtils.WakaTime(metadata, _logger); _logger.Debug("It will load WakaTime extension"); await InitializeAsync(cancellationToken); // Prompt for api key if not already set if (string.IsNullOrEmpty(_wakatime.Config.GetSetting("api_key"))) { PromptApiKey(); } }
protected override void Initialize() { base.Initialize(); ObjDte = (DTE)GetService(typeof(DTE)); var configuration = new Configuration { EditorName = "visualstudio", PluginName = "visualstudio-wakatime", EditorVersion = ObjDte == null ? string.Empty : ObjDte.Version }; WakaTime = new Shared.ExtensionUtils.WakaTime(this, configuration, new Logger()); // Only perform initialization if async package framework not supported if (WakaTime.IsAsyncLoadSupported) { return; } // Try force initializing in background WakaTime.Logger.Debug("Initializing in background thread."); Task.Run(() => { InitializeAsync(); }); }
protected override void Initialize() { base.Initialize(); AddSkipLoading(); _dte = (DTE)GetService(typeof(DTE)); _dteEvents = _dte.Events.DTEEvents; _dteEvents.OnStartupComplete += OnOnStartupComplete; var metadata = new Metadata { EditorName = "ssms", PluginName = "ssms-wakatime", EditorVersion = _dte == null ? string.Empty : _dte.Version, PluginVersion = Constants.PluginVersion }; _logger = new Logger(Dependencies.GetConfigFilePath()); _wakatime = new Shared.ExtensionUtils.WakaTime(metadata, _logger); _logger.Debug("It will load WakaTime extension"); Task.Run(() => { InitializeAsync(); }); }
private void WakaTimeAddin_Startup(object sender, System.EventArgs e) { var configuration = new Configuration { EditorName = "word", PluginName = "word-wakatime", EditorVersion = Application.Version, PluginVersion = Constants.PluginVersion }; WakaTime = new WakaTime.Shared.ExtensionUtils.WakaTime(null, configuration, new Logger()); WakaTime.Logger.Debug("Initializing in background thread."); Task.Run(() => { InitializeAsync(); }).ContinueWith(t => OnStartupComplete()); }