Cómo conectar los eventos WF4 WorkflowRuntime cuando se utiliza un servicio de XAMLX
-
04-10-2019 - |
Pregunta
Actualmente estoy usando un BehaviorExtensionElement para cargar un ServiceBehavior donde el método ApplyDispatchBehavior se configura como:
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
{
WorkflowServiceHost host = serviceHostBase as WorkflowServiceHost;
if (host != null)
{
UnityService.CreateContainer();
host.WorkflowExtensions.Add<IUnityContainer>(delegate { return UnityService.CreateChildContainer(); });
System.Diagnostics.Debug.WriteLine("NotificationService : Adding extension");
WorkflowRuntimeBehavior wfbehavior = serviceDescription.Behaviors.Find<WorkflowRuntimeBehavior>();
WorkflowRuntime runtime = wfbehavior.WorkflowRuntime;
runtime.WorkflowStarted += runtime_WorkflowStarted;
runtime.WorkflowCreated += runtime_WorkflowCreated;
runtime.WorkflowUnloaded += runtime_WorkflowUnloaded;
runtime.WorkflowSuspended += runtime_WorkflowSuspended;
runtime.WorkflowCompleted += runtime_WorkflowCompleted;
runtime.WorkflowAborted += runtime_WorkflowAborted;
runtime.WorkflowTerminated += runtime_WorkflowTerminated;
}
}
Ninguno de los eventos se desencadenan que sólo va a decir que la forma en que estoy haciendo referencia a la instancia de tiempo de ejecución en este escenario particular está mal.
Alguien sabe de una manera de hacer esto? Gracias de antemano.
Solución
El WorkflowRuntime y WorkflowRuntimeBehavior son artefactos Wf3 pero su pregunta es etiquetados como WF4 así que voy a suponer que está utilizando WF4.
En WF4 la manera de hacer esto es mediante el uso de un TrackingParticipant costumbre y agregó que a la colección de la WorkflowExtensions WorkflowServiceHost.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow