Export (0) Print
Expand All
Expand Minimize

ServiceCreatorCallback Delegate

Provides a callback mechanism that can create an instance of a service on demand.

Namespace: System.ComponentModel.Design
Assembly: System (in system.dll)

[ComVisibleAttribute(true)] 
public delegate Object ServiceCreatorCallback (
	IServiceContainer container,
	Type serviceType
)
/** @delegate */
/** @attribute ComVisibleAttribute(true) */ 
public delegate Object ServiceCreatorCallback (
	IServiceContainer container, 
	Type serviceType
)
Not applicable.

Parameters

container

The service container that requested the creation of the service.

serviceType

The type of service to create.

Return Value

The service specified by serviceType, or a null reference (Nothing in Visual Basic) if the service could not be created.

ServiceCreatorCallback provides a mechanism to publish services that you can request to have created when needed, rather than the service being created immediately when the designer loads. You can use a callback function if the service is not essential and may not be used. A service published by using a ServiceCreatorCallback does not use as many additional resources if it is not requested and created. To use a callback function to publish your service, pass a ServiceCreatorCallback to the AddService method of an IServiceContainer.

NoteNote:

The HostProtectionAttribute attribute applied to this class has the following Resources property value: SharedState. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

The following code example shows how to publish a service using a callback function.

// The following code shows how to publish a service using a callback function.

// Creates a service creator callback.
ServiceCreatorCallback callback1 = 
new ServiceCreatorCallback(myCallBackMethod);

// Adds the service using its type and the service creator callback.
serviceContainer.AddService(typeof(myService), callback1);

// The following code shows how to publish a service using a 
// callback function.
// Creates a service creator callback.
ServiceCreatorCallback callBack1 = new ServiceCreatorCallback(
    MyCallBackMethod);
// Adds the service using its type and the service creator callback.
serviceContainer.AddService(MyService.class.ToType(), callBack1);

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft