次の方法で共有


NSInstance.StartInstance Method

Notification Services のインスタンスの Notification Services エンジンを起動します。

名前空間: Microsoft.SqlServer.NotificationServices
アセンブリ: Microsoft.SqlServer.NotificationServices (microsoft.sqlserver.notificationservices.dll 内)

構文

'宣言
Public Sub StartInstance
public void StartInstance ()
public:
virtual void StartInstance () sealed
public final void StartInstance ()
public final function StartInstance ()

解説

Notification Services のインスタンスのコンポーネントを実行するコンピュータごとに、1 つの Notification Services エンジンがあります。このエンジンは、Notification Services のインスタンスの登録時に作成できる NS$instanceNameMicrosoft Windows サービス、またはカスタム アプリケーションやカスタム サービスでホストすることができます。

コンピュータで実行中の Notification Services のインスタンスは、StartInstance メソッドと StopInstance メソッドを使用して、開始または停止できます。

ms147281.note(ja-jp,SQL.90).gif重要 :
1 台のコンピュータで Notification Services のインスタンスを実行できるプロセスは 1 つだけです。たとえば、NS$instanceName Windows サービスを作成し、そのサービスを開始した後で独自のアプリケーションでインスタンスを開始しようとすると、Notification Services によってエラーがスローされます。

エンジンのホストについての詳細は、「Notification Services エンジンのホスト」を参照してください。

使用例

マネージ コードで NSInstance オブジェクトを作成、初期化および開始する例を次に示します。

' 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);
    }

スレッド セーフ

この型の public static (Microsoft Visual Basic では共有 ) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

プラットフォーム

開発プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

対象プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

参照

関連項目

NSInstance Class
NSInstance Members
Microsoft.SqlServer.NotificationServices Namespace