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 )
The service container that requested the creation of the service.
The type of service to create.
Return ValueThe 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.
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 = gcnew ServiceCreatorCallback( this, &Sample::myCallBackMethod ); // Adds the service using its type and the service creator callback. serviceContainer->AddService( myService::typeid, 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 EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.