NSInstance.StartInstance Method

Starts the Notification Services engine for an instance of Notification Services.

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

Sintaxis

'Declaración
Public Sub StartInstance
public void StartInstance ()
public:
virtual void StartInstance () sealed
public final void StartInstance ()
public final function StartInstance ()

Notas

On each computer that runs components of an instance of Notification Services, there is one Notification Services engine. This engine can be hosted by the NS$instanceNameMicrosoft Windows service, which can be created when you register an instance of Notification Services, or can be hosted by a custom application or service.

You can start and stop an instance of Notification Services on a computer using the StartInstance and StopInstance methods.

ms147281.note(es-es,SQL.90).gifImportante:
Only one process can run an instance of Notification Services on any computer. For example, if you create the NS$instanceName Windows service and start that service, and then attempt to start the instance in your own application, Notification Services will throw an error.

For more information about hosting the engine, see Alojar el motor de Notification Services.

Ejemplo

The following examples show how to create, initialize, and start an NSInstance object in managed code:

' Define an error handler for the hosted execution engine.
Private Sub MyErrorHandler(ByVal sender As Object, _
    ByVal e As ErrorEventArgs) Handles instance.Error
    Console.WriteLine(e.GetException().ToString())
End Sub

' Start the instance, using the error handler to
' handle any exceptions thrown by the running instance.
Public Sub StartInstance(ByVal myInstance As NSInstance)
    Try
        'Start the instance.
        myInstance.StartInstance()

        ' Verify that the hosted engine is running.
        If myInstance.IsRunning = True Then
            Console.WriteLine("The instance is running.")
        Else
            Console.WriteLine("The instance is NOT running!")
        End If

    Catch ex As Exception
        Console.WriteLine(ex.Message)
    End Try
// Define an error handler for the hosted execution engine.
private void MyErrorHandler(object sender, ErrorEventArgs e)
{
    Console.WriteLine(e.GetException().ToString());
}

// Start the instance, using the error handler to
// handle any exceptions thrown by the running instance.
public void StartInstance(NSInstance myInstance)
{
    try
    {
        // Add an error handler to the instance.
        myInstance.Error +=
            new NSInstance.ErrorEventHandler(MyErrorHandler);

        //Start the instance.
        myInstance.StartInstance();

        // Check the IsRunning property to verify that 
        // this process is running the instance.
        if (myInstance.IsRunning == true)
            Console.WriteLine("The instance is running.");
        else
            Console.WriteLine("The instance is NOT running!");

    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }

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

NSInstance Class
NSInstance Members
Microsoft.SqlServer.NotificationServices Namespace