WorkflowRuntime.WorkflowCreated WorkflowRuntime.WorkflowCreated WorkflowRuntime.WorkflowCreated WorkflowRuntime.WorkflowCreated Event

Definition

Tritt auf, wenn eine Workflowinstanz erstellt wird.Occurs when a workflow instance is created.

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

Beispiele

Das folgende Codebeispiel zeigt, wie Sie die WorkflowRuntime-Funktionalität eines Workflowhosts verwenden können.The following code example demonstrates how to use WorkflowRuntime functionality from a workflow host. Der Code ordnet WorkflowCreated einem Ereignishandler zu. Hierbei handelt es sich um eine Methode mit dem Namen OnWorkflowCreated.The code associates the WorkflowCreated with an event handler, a method named OnWorkflowCreated.

Dieses Codebeispiel ist Teil des Beispiel für den benutzerdefinierten Persistenzdienst.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

Hinweise

Die Workflowruntime-Engine löst das WorkflowCreated-Ereignis aus, nachdem die Workflowinstanz vollständig erstellt wurde, aber bevor die Aktivitäten verarbeitet wurden.The workflow run-time engine raises the WorkflowCreated event after the workflow instance is completely constructed but before activities are processed. Bei diesem Ereignis enthält der Absender die WorkflowRuntime und WorkflowEventArgs enthält die WorkflowInstance, die dem Ereignis zugeordnet ist.For this event, the sender contains the WorkflowRuntime and WorkflowEventArgs contains the WorkflowInstance associated with the event.

Weitere Informationen zur Behandlung von Ereignissen finden Sie unter behandeln und Auswerfen von Ereignissen.For more information about handling events, see Handling and raising events.

Gilt für: