Compartir a través de


EventCollector.Commit Method

Submits an event batch to the application database.

Espacio de nombres: Microsoft.SqlServer.NotificationServices
Ensamblado: Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)

Sintaxis

'Declaración
Public Function Commit As Integer
public int Commit ()
public:
virtual int Commit () sealed
public final int Commit ()
public final function Commit () : int

Valor devuelto

An integer specifying how many events have been submitted in this Commit call.

Notas

An event provider calls the Write method to submit an event (encapsulated as an Event) to an EventCollector. The EventCollector gathers all submitted events into an event batch. When the event provider calls the Commit method, the EventCollector submits the event batch to the Notification Services application database for processing.

The EventCollector creates a new event batch when the event provider first calls Write, and then again on the first Write call after an Abort or Commit call.

Ejemplo

The following examples show how to use the Commit method to commit an event batch.

These examples use the Microsoft.SqlServer.NotificationServices namespace.

Dim instanceName As String = "MyInstanceName"
Dim applicationName As String = "MyApplicationName"
Dim eventClassName As String = "MyEventClassName"
Dim eventProviderName As String = "MyEventProviderName"

'Create an NSInstance object.
Dim myInstance As New NSInstance(instanceName)

'Create an NSApplication object.
Dim myApplication As New NSApplication(myInstance, applicationName)

'Create an Event object.
Dim myEvent As New Microsoft.SqlServer.NotificationServices.Event( _
    myApplication, eventClassName)

'Create an EventCollector object.
Dim myEventCollector As _
    New EventCollector(myApplication, eventProviderName)

'Add code to collect event information here.

'Commit the event batch to the application database.
Dim eventsWritten As Integer = myEventCollector.Commit()
string instanceName = "MyInstanceName";
string applicationName = "MyApplicationName";
string eventClassName = "MyEventClassName";
string eventProviderName = "MyEventProviderName";

//Create an NSInstance object.
NSInstance myInstance = new NSInstance(instanceName);

//Create an NSApplication object.
NSApplication myApplication = 
    new NSApplication(myInstance, applicationName);

//Create an Event object.
Event myEvent = new Event(myApplication, eventClassName);

//Create an EventCollector object.
EventCollector myEventCollector = 
    new EventCollector(myApplication, eventProviderName);

//Add code to collect event information here.

//Commit the event batch to the application database.
int eventsWritten = myEventCollector.Commit();

Seguridad para subprocesos

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.

Plataformas

Plataformas de desarrollo

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Plataformas de destino

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Vea también

Referencia

EventCollector Class
EventCollector Members
Microsoft.SqlServer.NotificationServices Namespace