Aracılığıyla paylaş


AsyncPackage.AddService Method

Definition

Overloads

AddService(Type, AsyncServiceCreatorCallback)

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

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.

AddService(Type, AsyncServiceCreatorCallback, Boolean)

Adds an async service to this package, specifying whether the service will 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, AsyncServiceCreatorCallback)

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

public:
 virtual void AddService(Type ^ serviceType, Microsoft::VisualStudio::Shell::AsyncServiceCreatorCallback ^ callback);
public void AddService (Type serviceType, Microsoft.VisualStudio.Shell.AsyncServiceCreatorCallback callback);
abstract member AddService : Type * Microsoft.VisualStudio.Shell.AsyncServiceCreatorCallback -> unit
override this.AddService : Type * Microsoft.VisualStudio.Shell.AsyncServiceCreatorCallback -> unit
Public Sub AddService (serviceType As Type, callback As AsyncServiceCreatorCallback)

Parameters

serviceType
Type

The service identity of the service which can be later used to retrieve it.

callback
AsyncServiceCreatorCallback

The creation callback to be invoked when an instance of the service is needed. This is only invoked one time and the result is cached.

Implements

Exceptions

serviceType or callback is null.

Remarks

If the underlying service implements IDisposable and is requested and activated during the lifetime of the package, Dispose() will be called automatically by RemoveService(Type) or this package's Dispose(Boolean).

This method is safe to access from any thread.

Applies to

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.

public:
 virtual void AddService(Type ^ serviceType, Microsoft::VisualStudio::Shell::AsyncServiceCreatorWithProgressCallback ^ callback);
public void AddService (Type serviceType, Microsoft.VisualStudio.Shell.AsyncServiceCreatorWithProgressCallback callback);
abstract member AddService : Type * Microsoft.VisualStudio.Shell.AsyncServiceCreatorWithProgressCallback -> unit
override this.AddService : Type * Microsoft.VisualStudio.Shell.AsyncServiceCreatorWithProgressCallback -> unit
Public Sub AddService (serviceType As Type, callback As AsyncServiceCreatorWithProgressCallback)

Parameters

serviceType
Type

The service identity of the service which can be later used to retrieve it.

callback
AsyncServiceCreatorWithProgressCallback

The creation callback to be invoked when an instance of the service is needed. This is only invoked one time and the result is cached.

Implements

Exceptions

serviceType or callback is null.

Remarks

If the underlying service implements IDisposable and is requested and activated during the lifetime of the package, Dispose() will be called automatically by RemoveService(Type) or this package's Dispose(Boolean).

This method is safe to access from any thread.

Applies to

AddService(Type, AsyncServiceCreatorCallback, Boolean)

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

public:
 virtual void AddService(Type ^ serviceType, Microsoft::VisualStudio::Shell::AsyncServiceCreatorCallback ^ callback, bool promote);
public void AddService (Type serviceType, Microsoft.VisualStudio.Shell.AsyncServiceCreatorCallback callback, bool promote);
abstract member AddService : Type * Microsoft.VisualStudio.Shell.AsyncServiceCreatorCallback * bool -> unit
override this.AddService : Type * Microsoft.VisualStudio.Shell.AsyncServiceCreatorCallback * bool -> unit
Public Sub AddService (serviceType As Type, callback As AsyncServiceCreatorCallback, promote As Boolean)

Parameters

serviceType
Type

The service identity of the service which can be later used to retrieve it.

callback
AsyncServiceCreatorCallback

The creation callback to be invoked when an instance of the service is needed. This is only invoked one time and the result is cached.

promote
Boolean

true if this service should be visible outside this package, otherwise false.

Implements

Exceptions

serviceType or callback is null.

Remarks

Promoted services will be available to other packages and components via both the synchronous GlobalProvider and the asynchronous GlobalProvider.

If the underlying service implements IDisposable and is requested and activated during the lifetime of the package, Dispose() will be called automatically by RemoveService(Type) or this package's Dispose(Boolean).

This method is safe to access from any thread.

Applies to

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.

public:
 virtual void AddService(Type ^ serviceType, Microsoft::VisualStudio::Shell::AsyncServiceCreatorWithProgressCallback ^ callback, bool promote);
public void AddService (Type serviceType, Microsoft.VisualStudio.Shell.AsyncServiceCreatorWithProgressCallback callback, bool promote);
abstract member AddService : Type * Microsoft.VisualStudio.Shell.AsyncServiceCreatorWithProgressCallback * bool -> unit
override this.AddService : Type * Microsoft.VisualStudio.Shell.AsyncServiceCreatorWithProgressCallback * bool -> unit
Public Sub AddService (serviceType As Type, callback As AsyncServiceCreatorWithProgressCallback, promote As Boolean)

Parameters

serviceType
Type

The service type to be used as the identifier used for retrieving this service.

callback
AsyncServiceCreatorWithProgressCallback

The creation callback to be invoked when an instance of the service is needed. This is only invoked one time and the result is cached.

promote
Boolean

True if this service should be visible outside this package, otherwise false.

Implements

Applies to