WorkflowRuntime.WorkflowCreated Evento

Definición

Se produce cuando se crea una instancia de flujo de trabajo.

C#
public event EventHandler<System.Workflow.Runtime.WorkflowEventArgs> WorkflowCreated;

Tipo de evento

Ejemplos

El ejemplo de código siguiente muestra cómo se puede utilizar la funcionalidad WorkflowRuntime desde un host del flujo de trabajo. El código asocia WorkflowCreated a un controlador de eventos, un método denominado OnWorkflowCreated.

Este ejemplo de código forma parte del ejemplo de Custom Persistence Service.

C#
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");
        }
    }
}

Comentarios

El motor en tiempo de ejecución de flujo de trabajo genera el evento WorkflowCreated después de que la instancia de flujo de trabajo se haya construido completamente pero antes de que se procesen las actividades. Para este evento, el remitente contendrá WorkflowRuntime y WorkflowEventArgs contendrá el WorkflowInstance asociado al evento.

Para obtener más información sobre el control de eventos, consulte Control y generación de eventos.

Se aplica a

Producto Versiones
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1