WorkflowRuntime.ServicesExceptionNotHandled 이벤트

정의

WorkflowRuntimeService 클래스에서 파생된 서비스가 RaiseServicesExceptionNotHandledEvent(Exception, Guid)를 호출할 때 발생합니다.

public:
 event EventHandler<System::Workflow::Runtime::ServicesExceptionNotHandledEventArgs ^> ^ ServicesExceptionNotHandled;
public event EventHandler<System.Workflow.Runtime.ServicesExceptionNotHandledEventArgs> ServicesExceptionNotHandled;
member this.ServicesExceptionNotHandled : EventHandler<System.Workflow.Runtime.ServicesExceptionNotHandledEventArgs> 
Public Custom Event ServicesExceptionNotHandled As EventHandler(Of ServicesExceptionNotHandledEventArgs) 
Public Event ServicesExceptionNotHandled As EventHandler(Of ServicesExceptionNotHandledEventArgs) 

이벤트 유형

예제

다음 코드 예제에서는 워크플로 호스트에서 WorkflowRuntime 기능을 사용하는 방법을 보여 줍니다. 이 코드에서는 ServicesExceptionNotHandled를 이벤트 처리기인 OnExceptionNotHandled 메서드에 연결합니다.

일부인이 코드 예제는 Custom Persistence Service 샘플합니다.

static void Main()
{
    using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
    {
        try
        {
            // engine will unload workflow instance when it is idle
            workflowRuntime.AddService(new FilePersistenceService(true));

            workflowRuntime.WorkflowCreated += OnWorkflowCreated;
            workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
            workflowRuntime.WorkflowIdled += OnWorkflowIdle;
            workflowRuntime.WorkflowUnloaded += OnWorkflowUnload;
            workflowRuntime.WorkflowLoaded += OnWorkflowLoad;
            workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
            workflowRuntime.ServicesExceptionNotHandled += OnExceptionNotHandled;

            workflowRuntime.CreateWorkflow(typeof(PersistenceServiceWorkflow)).Start();

            waitHandle.WaitOne();
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception \n\t Source: {0} \n\t Message: {1}", e.Source, e.Message);
        }
        finally
        {
            workflowRuntime.StopRuntime();
            Console.WriteLine("Workflow runtime stopped, program exiting... \n");
        }
    }
}
Shared Sub Main()

    Using currentWorkflowRuntime As New WorkflowRuntime()
        Try

            ' engine will unload workflow instance when it is idle
            currentWorkflowRuntime.AddService(New FilePersistenceService(True))

            AddHandler currentWorkflowRuntime.WorkflowCreated, AddressOf OnWorkflowCreated
            AddHandler currentWorkflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted
            AddHandler currentWorkflowRuntime.WorkflowIdled, AddressOf OnWorkflowIdled
            AddHandler currentWorkflowRuntime.WorkflowUnloaded, AddressOf OnWorkflowUnloaded
            AddHandler currentWorkflowRuntime.WorkflowLoaded, AddressOf OnWorkflowLoaded
            AddHandler currentWorkflowRuntime.WorkflowTerminated, AddressOf OnWorkflowTerminated
            AddHandler currentWorkflowRuntime.ServicesExceptionNotHandled, AddressOf OnExceptionNotHandled

            currentWorkflowRuntime.CreateWorkflow(GetType(PersistenceServiceWorkflow)).Start()

            waitHandle.WaitOne()

        Catch e As Exception
            Console.WriteLine("Exception \n\t Source: 0} \n\t Message: 1}", e.Source, e.Message)
        Finally
            currentWorkflowRuntime.StopRuntime()
            Console.WriteLine("Workflow runtime stopped, program exiting... \n")
        End Try
    End Using
End Sub

설명

WorkflowRuntimeService 클래스에서 파생된 서비스는 처리할 수 없었던 예외가 실행 중에 발생했음을 RaiseServicesExceptionNotHandledEvent 이벤트에 대한 구독자에 알리기 위해 ServicesExceptionNotHandled 메서드를 호출할 수 있습니다. 복구 메커니즘을 구현하기 위해 이 이벤트를 구독할 수 있습니다.

워크플로 런타임 엔진이 워크플로 인스턴스를 만들기 전에 예외가 발생하면 이 이벤트가 발생합니다. 이 시나리오에서 호스트 애플리케이션에 예외가 발생했다고 알리는 유일한 방법은 이 이벤트를 발생시키는 것입니다. 그러나 워크플로 런타임 엔진이 직접 이 이벤트를 호출하지는 않습니다. 대신 워크플로 런타임 엔진은 예외를 워크플로 인스턴스로 전달하거나, 인스턴스가 없는 경우 호출자(이 경우 이 이벤트를 발생시킨 서비스)에 예외를 다시 throw합니다. 사용자가 직접 지속성 또는 스케줄러 서비스를 만드는 경우 기본 RaiseServicesExceptionNotHandledEvent 메서드를 통해 이 이벤트를 구현해야 합니다.

ServicesExceptionNotHandled 이벤트의 경우 발신자는 WorkflowRuntime을 포함하고 WorkflowEventArgs는 서비스를 사용하고 있던 워크플로 인스턴스의 Guid와 처리할 수 없었던 Exception을 포함합니다.

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생을 참조하세요.

적용 대상