WorkflowRuntime.WorkflowCreated Evento
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Se produce cuando se crea una instancia de flujo de trabajo.
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 Custom Event WorkflowCreated As EventHandler(Of WorkflowEventArgs)
Public Event WorkflowCreated As EventHandler(Of WorkflowEventArgs)
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.
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
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.