WorkflowRuntime.WorkflowLoaded Evento

Definição

Ocorre quando a instância de fluxo de trabalho é carregada na memória.Occurs when the workflow instance is loaded into memory.

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

Tipo de evento

EventHandler<WorkflowEventArgs>

Exemplos

O exemplo de código a seguir demonstra como usar a WorkflowRuntime funcionalidade de um host de fluxo de trabalho.The following code example demonstrates how to use WorkflowRuntime functionality from a workflow host. O código associa o a WorkflowLoaded um manipulador de eventos, um método chamado OnWorkflowLoad .The code associates the WorkflowLoaded with an event handler, a method named OnWorkflowLoad.

Este exemplo de código faz parte do exemplo de serviço de persistência personalizado .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

Comentários

WorkflowLoaded ocorre após o serviço de persistência ter restaurado a instância de fluxo de trabalho, mas antes de o mecanismo de tempo de execução do fluxo de trabalho começar a executar qualquer atividade.WorkflowLoaded occurs after the persistence service has restored the workflow instance, but before the workflow run-time engine begins to execute any activities.

Para o WorkflowLoaded evento, o remetente contém o WorkflowRuntime e WorkflowEventArgs contém o WorkflowInstance associado ao evento.For the WorkflowLoaded event, the sender contains the WorkflowRuntime and WorkflowEventArgs contains the WorkflowInstance associated with the event.

Para obter mais informações sobre como manipular eventos, consulte manipulando e gerando eventos.For more information about handling events, see Handling and raising events.

Aplica-se a