IEventProvider.Run Method
Activates the event provider to begin collecting events.
Spazio dei nomi: Microsoft.SqlServer.NotificationServices
Assembly : Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)
Sintassi
'Dichiarazione
Function Run As Boolean
bool Run ()
bool Run ()
boolean Run ()
function Run () : boolean
Valore restituito
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.
Osservazioni
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.
Esempio
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.
Piattaforme
Piattaforme di sviluppo
Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.
Piattaforme di destinazione
Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.
Vedere anche
Riferimento
IEventProvider Interface
IEventProvider Members
Microsoft.SqlServer.NotificationServices Namespace