Share via


IEventProvider.Run Method

Activates the event provider to begin collecting events.

Namespace: Microsoft.SqlServer.NotificationServices
Assembly: Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)

Syntax

'Declaration
Function Run As Boolean
bool Run ()
bool Run ()
boolean Run ()
function Run () : boolean

Return Value

A Boolean value; true if the event provider is running successfully and false if the event provider is not running successfully and the provider host must call the Terminate method.

Remarks

The provider host calls this method to tell the continuous event provider to start collecting events.

The provider hosts starts continuous event providers when the instance of Notification Services starts, and they run continuously while the application is active. When the instance starts, the provider host calls the Initialize and Run methods on the continuous event provider just once. Once started, a continuous event provider runs and submits events until its Terminate method is called.

The event provider must return from the Run method within timeout period configured in the ADF (which has a default of five minutes), using the initial thread allocated to it by the provider host. You must program the event provider to either use a callback function, or to gather and submit events on one or more separate threads. If you choose to have multiple threads running in parallel and if event order is important to your application, make sure to synchronize the threads so that they submit events to the database in the same order in which they were created.

A continuous event provider can return false from the Run method to let the provider host know something is wrong and that it is not going to continue to run. If the continuous event provider has already returned from Run and is now submitting events on a separate thread, then it must use the StopHandler delegate to notify the provider host that something has gone wrong. This delegate is passed to the event provider as an argument to the Initialize method, so that the event provider can invoke it if it needs to be terminated.

Hosted event providers must catch and handle their own exceptions. If the exceptions are not handled, the provider host logs the unhandled error and then invokes the Terminate method on the event provider.

Example

For an example of how to implement the Run method, see the IEventProvider topic.

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

Target Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

See Also

Reference

IEventProvider Interface
IEventProvider Members
Microsoft.SqlServer.NotificationServices Namespace