/// <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> protected override async Task InitializeAsync( CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress); // When initialized asynchronously, we *may* be on a background thread at // this point. Do any initialization that requires the UI thread after // switching to the UI thread. Otherwise, remove the switch to the UI // thread if you don't need it. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); CommentMyCode.Initialize(this); }
} // end of property - Instance /************************ Static *****************************************/ /*----------------------- Initialize ------------------------------------*/ /// <summary> /// Initializes expecting a valid package /// </summary> /// <param name="package"></param> /// <returns></returns> /// <remarks> /// Will throw an <see cref="InvalidOperationException"/> exception if /// this has already been initialized /// </remarks> public static CommentMyCode Initialize(Package package) { if (null == package) { throw new ArgumentNullException("Package cannot be null"); } if (INSTANCE != null) { throw new InvalidOperationException("Already initialized"); } ProviderFactory.Initialize(); return(INSTANCE = new CommentMyCode(package)); } // end of function - Initialize