WorkflowRuntime.WorkflowUnloaded 이벤트

정의

워크플로 인스턴스가 메모리에서 언로드될 때 발생합니다.

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

이벤트 유형

예제

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

일부인이 코드 예제는 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

설명

워크플로 인스턴스는 Unload에 대한 명시적 호출에 의해, 또는 워크플로 런타임 엔진에서 해당 의미 체계에 따라 암시적으로 언로드될 수 있습니다. 인스턴스가 유휴 상태가 되 고 런타임에 경우 워크플로 런타임 엔진에서 워크플로 인스턴스를 언로드합니다 하는 예를 들어, 한 WorkflowPersistenceService 를 추가 UnloadOnIdletrue합니다.

워크플로 런타임 엔진은 워크플로 instance 상태가 성공적으로 유지되었지만 메모리에서 instance 무효화되기 전에 이벤트를 발생 WorkflowUnloaded 합니다. 따라서 WorkflowPersisted 이벤트는 WorkflowUnloaded 이벤트보다 먼저 발생합니다.

WorkflowUnloaded 이벤트의 경우 발신자는 WorkflowRuntime을 포함하고 WorkflowEventArgs는 이벤트와 연결된 WorkflowInstance를 포함합니다.

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

적용 대상