WorkflowRuntime.WorkflowUnloaded WorkflowRuntime.WorkflowUnloaded WorkflowRuntime.WorkflowUnloaded WorkflowRuntime.WorkflowUnloaded Event

정의

워크플로 인스턴스가 메모리에서 언로드될 때 발생합니다.Occurs when the workflow instance is unloaded from memory.

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 Event WorkflowUnloaded As EventHandler(Of WorkflowEventArgs) 

예제

다음 코드 예제에서는 워크플로 호스트에서 WorkflowRuntime 기능을 사용하는 방법을 보여 줍니다.The following code example demonstrates how to use WorkflowRuntime functionality from a workflow host. 이 코드에서는 WorkflowUnloaded를 이벤트 처리기인 OnWorkflowUnload 메서드에 연결합니다.The code associates the WorkflowUnloaded with an event handler, a method named OnWorkflowUnload.

일부인이 코드 예제는 Custom Persistence Service 샘플합니다.This code example is part of the Custom Persistence Service Sample.

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에 대한 명시적 호출에 의해, 또는 워크플로 런타임 엔진에서 해당 의미 체계에 따라 암시적으로 언로드될 수 있습니다.A workflow instance can be unloaded from memory by an explicit call to Unload, or implicitly by the workflow run-time engine according to its own semantics. 인스턴스가 유휴 상태가 되 고 런타임에 경우 워크플로 런타임 엔진에서 워크플로 인스턴스를 언로드합니다 하는 예를 들어, 한 WorkflowPersistenceService 를 추가 UnloadOnIdletrue합니다.For example, the workflow run-time engine unloads a workflow instance if the instance becomes idle and the runtime has a WorkflowPersistenceService added for which UnloadOnIdle is true.

워크플로 런타임 엔진은 워크플로 인스턴스의 상태가 성공적 WorkflowUnloaded 으로 지속 된 후, 인스턴스가 메모리에서 무효화 되기 전에 이벤트를 발생 시킵니다.The workflow run-time engine raises the WorkflowUnloaded event after the state of the workflow instance has been successfully persisted but before the instance is invalidated in memory. 따라서 WorkflowPersisted 이벤트는 WorkflowUnloaded 이벤트보다 먼저 발생합니다.Therefore, a WorkflowPersisted event precedes the WorkflowUnloaded event.

WorkflowUnloaded 이벤트의 경우 발신자는 WorkflowRuntime을 포함하고 WorkflowEventArgs는 이벤트와 연결된 WorkflowInstance를 포함합니다.For the WorkflowUnloaded event, the sender contains the WorkflowRuntime and WorkflowEventArgs contains the WorkflowInstance associated with the event.

이벤트를 처리 하는 방법에 대 한 자세한 내용은 이벤트 처리 및 발생을 참조 하세요.For more information about handling events, see Handling and raising events.

적용 대상