Provides a callback mechanism that can create an instance of a service on demand.
[Visual Basic] <Serializable> <ComVisible(True)> Public Delegate Function Sub ServiceCreatorCallback( _ ByVal container As IServiceContainer, _ ByVal serviceType As Type _ ) As Object [C#] [Serializable] [ComVisible(true)] public delegate object ServiceCreatorCallback( IServiceContainer container, Type serviceType ); [C++] [Serializable] [ComVisible(true)] public __gc __delegate Object* ServiceCreatorCallback( IServiceContainer* container, Type* serviceType );
[JScript] In JScript, you can use the delegates in the .NET Framework, but you cannot define your own.
The declaration of your callback method must have the same parameters as the ServiceCreatorCallback delegate declaration.
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.
[Visual Basic, C#] The following code example shows how to publish a service using a callback function:
[Visual Basic] ' The following code shows how to publish a service using a callback function. ' Creates a service creator callback. Dim callback1 As New ServiceCreatorCallback _ (AddressOf myCallBackMethod) ' Adds the service using its type and the service creator. serviceContainer.AddService(GetType(myService), callback1) [C#] // 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);
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Namespace: System.ComponentModel.Design
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
System.ComponentModel.Design Namespace | AddService | IServiceContainer