Share via


AsyncPackage Class

Definition

Represents a VSPackage that can handle asynchronous services.

public ref class AsyncPackage abstract : Microsoft::VisualStudio::Shell::Package, Microsoft::VisualStudio::Shell::IAsyncServiceContainer, Microsoft::VisualStudio::Shell::IAsyncServiceProvider, Microsoft::VisualStudio::Shell::Interop::IAsyncLoadablePackageInitialize, Microsoft::VisualStudio::Shell::Interop::IAsyncServiceProvider
public ref class AsyncPackage abstract : Microsoft::VisualStudio::Shell::Package, Microsoft::VisualStudio::Shell::IAsyncServiceContainer, Microsoft::VisualStudio::Shell::IAsyncServiceProvider2, Microsoft::VisualStudio::Shell::Interop::IAsyncLoadablePackageInitialize, Microsoft::VisualStudio::Shell::Interop::IAsyncServiceProvider, Microsoft::VisualStudio::Shell::Interop::IVsAsyncToolWindowFactory, Microsoft::VisualStudio::Shell::Interop::IVsAsyncToolWindowFactoryProvider
public ref class AsyncPackage abstract : Microsoft::VisualStudio::Shell::Package, Microsoft::VisualStudio::Shell::IAsyncServiceContainer, Microsoft::VisualStudio::Shell::IAsyncServiceProvider2, Microsoft::VisualStudio::Shell::Interop::COMAsyncServiceProvider::IAsyncServiceProvider, Microsoft::VisualStudio::Shell::Interop::IAsyncLoadablePackageInitialize, Microsoft::VisualStudio::Shell::Interop::IVsAsyncToolWindowFactory, Microsoft::VisualStudio::Shell::Interop::IVsAsyncToolWindowFactoryProvider
[Windows::Foundation::Metadata::WebHostHidden]
public ref class AsyncPackage abstract : Microsoft::VisualStudio::Shell::Package, Microsoft::VisualStudio::Shell::IAsyncServiceContainer, Microsoft::VisualStudio::Shell::IAsyncServiceProvider, Microsoft::VisualStudio::Shell::IAsyncServiceProvider2, Microsoft::VisualStudio::Shell::Interop::IAsyncLoadablePackageInitialize, Microsoft::VisualStudio::Shell::Interop::IAsyncServiceProvider, Microsoft::VisualStudio::Shell::Interop::IVsAsyncToolWindowFactory, Microsoft::VisualStudio::Shell::Interop::IVsAsyncToolWindowFactoryProvider
[Windows::Foundation::Metadata::WebHostHidden]
class AsyncPackage abstract : Microsoft::VisualStudio::Shell::Package, Microsoft::VisualStudio::Shell::IAsyncServiceContainer, Microsoft::VisualStudio::Shell::IAsyncServiceProvider, Microsoft::VisualStudio::Shell::IAsyncServiceProvider2, Microsoft::VisualStudio::Shell::Interop::IAsyncLoadablePackageInitialize, Microsoft::VisualStudio::Shell::Interop::IAsyncServiceProvider, Microsoft::VisualStudio::Shell::Interop::IVsAsyncToolWindowFactory, Microsoft::VisualStudio::Shell::Interop::IVsAsyncToolWindowFactoryProvider
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class AsyncPackage : Microsoft.VisualStudio.Shell.Package, Microsoft.VisualStudio.Shell.IAsyncServiceContainer, Microsoft.VisualStudio.Shell.IAsyncServiceProvider, Microsoft.VisualStudio.Shell.Interop.IAsyncLoadablePackageInitialize, Microsoft.VisualStudio.Shell.Interop.IAsyncServiceProvider
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class AsyncPackage : Microsoft.VisualStudio.Shell.Package, Microsoft.VisualStudio.Shell.IAsyncServiceContainer, Microsoft.VisualStudio.Shell.IAsyncServiceProvider2, Microsoft.VisualStudio.Shell.Interop.IAsyncLoadablePackageInitialize, Microsoft.VisualStudio.Shell.Interop.IAsyncServiceProvider, Microsoft.VisualStudio.Shell.Interop.IVsAsyncToolWindowFactory, Microsoft.VisualStudio.Shell.Interop.IVsAsyncToolWindowFactoryProvider
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class AsyncPackage : Microsoft.VisualStudio.Shell.Package, Microsoft.VisualStudio.Shell.IAsyncServiceContainer, Microsoft.VisualStudio.Shell.IAsyncServiceProvider3, Microsoft.VisualStudio.Shell.Interop.COMAsyncServiceProvider.IAsyncServiceProvider, Microsoft.VisualStudio.Shell.Interop.IAsyncLoadablePackageInitialize, Microsoft.VisualStudio.Shell.Interop.IVsAsyncToolWindowFactory, Microsoft.VisualStudio.Shell.Interop.IVsAsyncToolWindowFactoryProvider
[<System.Runtime.InteropServices.ComVisible(true)>]
type AsyncPackage = class
    inherit Package
    interface IAsyncServiceProvider
    interface IAsyncLoadablePackageInitialize
    interface IAsyncServiceProvider
    interface IAsyncServiceContainer
[<System.Runtime.InteropServices.ComVisible(true)>]
type AsyncPackage = class
    inherit Package
    interface IAsyncServiceProvider
    interface IAsyncLoadablePackageInitialize
    interface IAsyncServiceProvider2
    interface IAsyncServiceProvider
    interface IAsyncServiceContainer
    interface IVsAsyncToolWindowFactory
    interface IVsAsyncToolWindowFactoryProvider
[<System.Runtime.InteropServices.ComVisible(true)>]
type AsyncPackage = class
    inherit Package
    interface IAsyncLoadablePackageInitialize
    interface IVsAsyncToolWindowFactory
    interface IVsAsyncToolWindowFactoryProvider
    interface IAsyncServiceProvider
    interface IAsyncServiceProvider3
    interface IAsyncServiceProvider2
    interface IAsyncServiceProvider
    interface IAsyncServiceContainer
Public MustInherit Class AsyncPackage
Inherits Package
Implements IAsyncLoadablePackageInitialize, IAsyncServiceContainer, IAsyncServiceProvider, IAsyncServiceProvider
Public MustInherit Class AsyncPackage
Inherits Package
Implements IAsyncLoadablePackageInitialize, IAsyncServiceContainer, IAsyncServiceProvider, IAsyncServiceProvider2, IVsAsyncToolWindowFactory, IVsAsyncToolWindowFactoryProvider
Public MustInherit Class AsyncPackage
Inherits Package
Implements IAsyncLoadablePackageInitialize, IAsyncServiceContainer, IAsyncServiceProvider, IAsyncServiceProvider3, IVsAsyncToolWindowFactory, IVsAsyncToolWindowFactoryProvider
Inheritance
AsyncPackage
Derived
Attributes
Implements

Constructors

AsyncPackage()

AsyncPackage default constructor.

Properties

ApplicationRegistryRoot

Gets the root registry key of the current Visual Studio registry hive.

(Inherited from Package)
DisposalToken

Exposes a CancellationToken that can be used to check if the package has been disposed. This can happen for async tasks that are running on a background thread when Visual Studio has started to shut down. Use ShutdownToken for an earlier indication that VS is shutting down.

JoinableTaskCollection

Gets the collection of asynchronous tasks started by this package.

JoinableTaskFactory

Gets the factory to use for asynchronous tasks started by this package.

UserDataPath

Gets the path to user data storage for Visual Studio.

(Inherited from Package)
UserLocalDataPath

Returns the path to user data storage for Visual Studio. Typically this is %USERPROFILE%\Local Settings\Application Data
Visual Studio[ver] but this can change based on any alternate root that the shell was initialized with.

(Inherited from Package)
UserRegistryRoot

Returns the registry root for the current user. Typically this is HKCU\Software\Microsoft\VisualStudio[ver] but this can change based on any alternate root that the shell is initialized with. This key is read-write.

(Inherited from Package)
Zombied

Gets a value indicating whether the package in the process of shutdown.

(Inherited from Package)

Methods

AddOptionKey(String)

Adds a user option key name into the list of option keys.

(Inherited from Package)
AddService(Type, AsyncServiceCreatorCallback, Boolean)

Adds an async service to this package, specifying whether the service will be visible outside of this package.

AddService(Type, AsyncServiceCreatorCallback)

Adds an async service to this package. The service will not be visible outside of this package.

AddService(Type, AsyncServiceCreatorWithProgressCallback, Boolean)

Adds an async service to this package that supports progress updates during initialization. This service may or may not be visible outside of this package, depending on the value of promote.

AddService(Type, AsyncServiceCreatorWithProgressCallback)

Adds an async service that supports progress updates during initialization to this package. The service will not be visible outside of this package.

CreateInstance(Guid, Guid, Type)

Create the specified COM object using Visual Studio's ILocalRegistry and cast it to the given managed type. If VS cannot create it, then fall back to Activator.CreateInstance. This allows managed classes to be registered in local to the particular VS version in HKLM\Software\Microsoft\VisualStudio\8.0\clsid.

(Inherited from Package)
CreateSettingsObserverAsync(Type, SettingsObserverArguments, CancellationToken)

Creates a settings observer object for the package. This method is called when unified settings are active, but only if the package has one or more ProvideSettingsObserverAttributes.

(Inherited from Package)
CreateTool(Guid)

Enables derived classes to provide an implementation if necessary.

(Inherited from Package)
CreateToolWindow(Guid, Int32)

Creates a tool window of the specified type with the specified ID.

(Inherited from Package)
CreateToolWindow(Type, Int32, Object)

Create a tool window of the specified type with the specified ID.

(Inherited from Package)
CreateToolWindow(Type, Int32, UInt32, Object, Guid)

Create a tool window of the specified type with the specified ID. This is the only method that should be calling IVsUiShell.CreateToolWindow()

(Inherited from Package)
CreateToolWindow(Type, Int32, UInt32)

Creates a tool window of the specified type with the specified ID.

(Inherited from Package)
CreateToolWindow(Type, Int32)

Creates a tool window of the specified type with the specified ID.

(Inherited from Package)
Dispose(Boolean)

Disposes the object and the associated cancellation token.

FindToolWindow(Type, Int32, Boolean)

Gets the tool window corresponding to the specified type and ID.

(Inherited from Package)
FindToolWindowAsync(Type, Int32, Boolean, CancellationToken)

Asynchronously locates the tool window corresponding to the specified type and ID. If it does not exist, it creates and returns one if create is true, or returns null if create is false.

FindWindowPane(Type, Int32, Boolean)

Gets the window pane corresponding to the specified type and ID, and if no window pane of that type exists creates one if told to do so.

(Inherited from Package)
FindWindowPaneAsync(Type, Int32, Boolean, CancellationToken)

Asynchronously locates the window pane corresponding to the specified type and ID. If it does not exist, it creates and returns one if create is true, or returns null if create is false.

GetAsyncToolWindowFactory(Guid)

Returns the asynchronous tool window factory interface for the tool window identified by toolWindowType, if asynchronous creation is supported for the tool window. If asynchronous creation is not supported, null is returned.

GetAutomationObject(String)

Gets the automation object for the VSPackage.

(Inherited from Package)
GetDialogPage(Type)

Gets the requested dialog page.

(Inherited from Package)
GetOutputPane(Guid, String)

Gets the requested output window.

(Inherited from Package)
GetProviderLocale()

Returns the locale associated with this service provider.

(Inherited from Package)
GetService(Type)

Retrieves a service registered with this package synchronously, falling back to the asynchronous GlobalProvider and synchronous GlobalProvider if there is no service with this identity registered with the package.

GetServiceAsync(Type, Boolean)

Retrieves an async service registered with this package asynchronously, falling back to the asynchronous GlobalProvider and synchronous GlobalProvider if there is no service with this identity registered with the package. It also allows specifying a hint whether to throw an exception if it could not be retrieved, it does not, however, guarantee exceptions will be thrown for all failure cases.

GetServiceAsync(Type)

Retrieves an async service registered with this package asynchronously, falling back to the asynchronous GlobalProvider and synchronous GlobalProvider if there is no service with this identity registered with the package.

GetServiceAsync<TService,TInterface>(Boolean, CancellationToken)

Retrieves an async service registered with this package asynchronously, falling back to the asynchronous GlobalProvider and synchronous GlobalProvider if there is no service with this identity registered with the package. It also allows specifying whether to throw an exception if it could not be retrieved.

GetToolboxItemData(String, DataFormats+Format)

Gets the content of the data format for the specified toolbox item ID and data format.

(Inherited from Package)
GetToolboxItemDataAsync(String, DataFormats+Format) (Inherited from Package)
GetToolWindowTitle(Type, Int32)

Returns the title string to use for the tool window. If null is returned, the tool window's type name is used for the title.

Initialize()

Seal this method. Due to an almost unavoidable risk of deadlock, SetSite (which is what calls Initialize) still occurs on the UI thread even for async package. Since most async package authors would, logically, assume that Initialize happens on a b/g thread they may do expensive (synchronous) things inside of their override, defeating some of the benefit of async loads. To help lead them away from that we will seal it and thus all they can override is async initialize, which is called on the b/g thread.

InitializeAsync(CancellationToken, IProgress<ServiceProgressData>)

When overridden in a derived class, asynchronously initializes the package. This method is invoked from a background thread.

InitializeToolWindowAsync(Type, Int32, CancellationToken)

Performs initialization in preparation for creating the tool window identified by toolWindowType.

InstantiateToolWindow(Type, Object)

Construct a tool window of the specified type.

(Inherited from Package)
InstantiateToolWindow(Type) (Inherited from Package)
IsLocalService(Type)

Determines whether the specified service type can be retrieved without requiring an RPC transition to the UI thread.

(Inherited from Package)
OnAfterPackageLoadedAsync(CancellationToken)

When overridden by a derived class, may initiate operations with side effects that are not strictly part of package load that would belong to InitializeAsync(CancellationToken, IProgress<ServiceProgressData>) that should happen soon after package load (e.g. updating command status). This method is invoked from a background thread.

OnLoadOptions(String, Stream)

Invoked by the package class when there are options to be read out of the solution file.

(Inherited from Package)
OnSaveOptions(String, Stream)

Invoked by the Package class when there are options to be saved to the solution file.

(Inherited from Package)
ParseToolboxResource(TextReader, Guid)

Parses an embedded text resource of appropriate format for information about which items should be added to the Toolbox.

(Inherited from Package)
ParseToolboxResource(TextReader, ResourceManager)

Parses an embedded text resource of appropriate format for information about which items should be added to the Toolbox.

(Inherited from Package)
QueryClose(Boolean)

Called to ask the package if the shell can be closed.

(Inherited from Package)
RegisterEditorFactory(IVsEditorFactory)

Registers an editor factory with Visual Studio.

(Inherited from Package)
RegisterProjectFactory(IVsProjectFactory)

Registers a project factory with Visual Studio.

(Inherited from Package)
RemoveService(Type, Boolean)

Removes an async service registered with this package.

RemoveService(Type)

Removes an async service registered with this package.

ShowOptionPage(Type)

Displays a specified tools options page.

(Inherited from Package)
ShowToolWindowAsync(Type, Int32, Boolean, CancellationToken)

Asynchronously shows the tool window corresponding to the specified type and ID. If it does not exist, it creates and returns one if create is true, or returns null if create is false.

Events

ToolboxInitialized

Event generated whenever Visual Studio initializes its Toolbox.

(Inherited from Package)
ToolboxUpgraded

Event generated whenever Visual Studio upgrades its Toolbox.

(Inherited from Package)

Explicit Interface Implementations

IAsyncLoadablePackageInitialize.Initialize(IAsyncServiceProvider, IProfferAsyncService, IAsyncProgressCallback)

Async version of SetSite, mostly called from a background thread, but not always.

IAsyncLoadablePackageInitialize.Initialize(IAsyncServiceProvider, IProfferAsyncService, IAsyncProgressCallback)

Async version of SetSite, called from a b/g thread.

IAsyncServiceProvider.QueryServiceAsync(Guid)

Get an async initializing service that is offered by this package.

IAsyncServiceProvider.QueryServiceAsync(Guid)

Get an async initializing service that is offered by this package.

IOleCommandTarget.Exec(Guid, UInt32, UInt32, IntPtr, IntPtr)

Executes a specified command or displays help for a command.

(Inherited from Package)
IOleCommandTarget.QueryStatus(Guid, UInt32, OLECMD[], IntPtr)

Queries the object for the status of one or more commands generated by user interface events.

(Inherited from Package)
IServiceContainer.AddService(Type, Object, Boolean)

Adds the given service to the VSPackage's service container.

(Inherited from Package)
IServiceContainer.AddService(Type, Object)

Adds the given service to the VSPackage's service container.

(Inherited from Package)
IServiceContainer.AddService(Type, ServiceCreatorCallback, Boolean)

Adds the given service to the service container by means of the specified ServiceCreatorCallback.

(Inherited from Package)
IServiceContainer.AddService(Type, ServiceCreatorCallback)

Adds the given service to the VSPackage's service container.

(Inherited from Package)
IServiceContainer.RemoveService(Type, Boolean)

Removes the given service type from the service container, and optionally promotes the removal of the service to parent service containers.

(Inherited from Package)
IServiceContainer.RemoveService(Type)

Removes the given service type from the service container.

(Inherited from Package)
IServiceProvider.GetService(Type)

Gets the service of the specified type.

(Inherited from Package)
IServiceProvider.QueryService(Guid, Guid, IntPtr)

Internal IServiceProvider implementation.

(Inherited from Package)
IVsAsyncToolWindowFactory.CreateToolWindow(Guid, UInt32, Object)

Creates a tool window of the specified type with the specified ID.

IVsAsyncToolWindowFactory.GetToolWindowTitle(Guid, UInt32)

Returns the title string to use for the tool window. If null is returned, the tool window's type name is used for the title.

IVsAsyncToolWindowFactory.InitializeToolWindowAsync(Guid, UInt32)

Performs initialization in preparation for creating the tool window identified by toolWindowType.

IVsAsyncUnifiedSettingsObserverFactory.CreateSettingsObserverAsync(Guid)

Instantiates Unified Settings observer identified by the given guid.

(Inherited from Package)
IVsPackage.Close()

Closes and disposes the package.

(Inherited from Package)
IVsPackage.GetAutomationObject(String, Object)

Gets an automation-friendly object for this package.

(Inherited from Package)
IVsPackage.GetPropertyPage(Guid, VSPROPSHEETPAGE[])

Proffers access to the Tools menu Options and the property pages of the Customize Toolbox dialog boxes.

(Inherited from Package)
IVsPackage.QueryClose(Int32)

Called to ask the VSPackage if the Visual Studio shell can be closed.

(Inherited from Package)
IVsPackage.ResetDefaults(UInt32)

Resets Toolbox defaults.

(Inherited from Package)
IVsPackage.SetSite(IServiceProvider)

Initializes the VSPackage in the Visual Studio environment.

(Inherited from Package)
IVsPersistSolutionOpts.LoadUserOptions(IVsSolutionPersistence, UInt32)

Loads user options for a given solution.

(Inherited from Package)
IVsPersistSolutionOpts.ReadUserOptions(IStream, String)

Reads user options for a given solution.

(Inherited from Package)
IVsPersistSolutionOpts.SaveUserOptions(IVsSolutionPersistence)

Saves user options for a given solution.

(Inherited from Package)
IVsPersistSolutionOpts.WriteUserOptions(IStream, String)

Writes user options for a given solution.

(Inherited from Package)
IVsToolboxItemProvider.GetItemContent(String, UInt16, IntPtr)

Gets an item.

(Inherited from Package)
IVsToolboxItemProvider2.GetItemContentAsync(String, UInt16) (Inherited from Package)
IVsToolWindowFactory.CreateToolWindow(Guid, UInt32)

Creates a tool window of the specified type with the specified ID.

(Inherited from Package)
IVsUserSettings.ExportSettings(String, IVsSettingsWriter)

This method implements the IVsUserSettings Interface used to manage profiles and import/export settings to XML files.

(Inherited from Package)
IVsUserSettings.ImportSettings(String, IVsSettingsReader, UInt32, Int32)

Retrieves a VSPackage's configuration using the Visual Studio settings mechanism when a user selects the import option of the Import/Export Settings feature on the IDE’s Tools menu. This method is part of the implementation of the IVsUserSettings interface used to manage profiles and import/export settings to XML files.

(Inherited from Package)
IVsUserSettingsMigration.MigrateSettings(IVsSettingsReader, IVsSettingsWriter, String)

Migrates settings from a previous version.

(Inherited from Package)
IVsUserSettingsQuery.NeedExport(String, Int32)

Determines whether settings have changed and should be re-exported.

(Inherited from Package)

Extension Methods

ProfferService<TService>(IAsyncServiceContainer, Func<CancellationToken,Task<Object>>, Boolean)

Proffers a service implemented by the specified type to an async service container. When the service is queried the first time, the creator function will be called.

ProfferService<TService>(IAsyncServiceContainer, Func<CancellationToken,Task<Object>>)

Proffers a service implemented by the specified type to an async service container. When the service is queried the first time, the creator function will be called. The proffered service will be promoted to the parent async service container.

ProfferService<TService>(IAsyncServiceContainer, Func<Task<Object>>, Boolean)

Proffers a service implemented by the specified type to an async service container. When the service is queried the first time, the creator function will be called.

ProfferService<TService>(IAsyncServiceContainer, Func<Task<Object>>)

Proffers a service implemented by the specified type to an async service container. When the service is queried the first time, the creator function will be called. The proffered service will be promoted to the parent async service container.

QueryService(IServiceProvider, Guid)

Gets a service exposed by a service provider based on its service GUID.

QueryService<TService>(IServiceProvider)

Gets a service exposed by a service provider based on its service type.

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider, Boolean, CancellationToken)

Retrieves a proffered service asynchronously, specifying whether to throw an exception if it could not be retrieved.

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider, Boolean)

Retrieves a proffered service asynchronously, specifying whether to throw an exception if it could not be retrieved.

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider, CancellationToken)

Retrieves a proffered service asynchronously, throwing an exception if it could not be retrieved.

GetServiceAsync<TService,TInterface>(IAsyncServiceProvider)

Retrieves a proffered service asynchronously, throwing an exception if it could not be retrieved.

Applies to