NSInstance.ErrorEventHandler Delegate
Represents the method that will handle the Error event of an NSInstance.
네임스페이스: Microsoft.SqlServer.NotificationServices
어셈블리: Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)
구문
‘선언
Public Delegate Sub ErrorEventHandler ( _
sender As Object, _
e As ErrorEventArgs _
)
public delegate void ErrorEventHandler (
Object sender,
ErrorEventArgs e
)
public delegate void ErrorEventHandler (
Object^ sender,
ErrorEventArgs^ e
)
/** @delegate */
public delegate void ErrorEventHandler (
Object sender,
ErrorEventArgs e
)
JScript는 대리자의 사용을 지원하지만 새로 선언하는 것은 지원하지 않습니다.
매개 변수
- sender
The NSInstance object that raised the error.
- e
The ErrorEventArgs object that contains the event data.
주의
When you host the Notification Services engine, implement this delegate to be notified of fatal errors that terminate the thread running the Notification Services engine. If the engine thread throws a fatal error that is not otherwise handled, Notification Services logs the error and calls this delegate.
예
While the instance is running, it may encounter run-time errors. These errors are reported back to the hosting process through a NSInstance.ErrorEventHandler delegate that is invoked when the Error event is triggered. When the event is raised, the delegate is called to notify the host, and the instance is stopped.
The following example shows how to respond to this event:
// Define an error handler for the hosted execution engine.
private void InstanceErrorHandler(object sender, ErrorEventArgs e)
{
Console.WriteLine (e.GetException ().ToString ());
}
// Start and stop the hosted execution engine.
public void ErrorHandlingStartStop()
{
try
{
// Instantiate the Notification Services instance.
NSInstance nsInstance = new NSInstance("FlightInstance");
// Add an error handler to the instance.
nsInstance.Error +=
new NSInstance.ErrorEventHandler(InstanceErrorHandler);
// Start the instance.
Console.WriteLine("Starting instance...");
nsInstance.StartInstance();
// Check the IsRunning property to verify that
// this process is running the instance.
if (nsInstance.IsRunning == true)
Console.WriteLine("The instance is running.");
else
Console.WriteLine("The instance is NOT running!");
// Stop the instance.
Console.WriteLine("Stopping instance...");
nsInstance.StopInstance();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
플랫폼
개발 플랫폼
지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.
대상 플랫폼
지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.