开发者

How to hook up WF4 WorkflowRuntime events when using a XAMLX service

I'm currently using a BehaviorExtensionElement to load a ServiceBehavior where the ApplyDispatchBehavior method is set up as:

    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 开发者_Go百科+= runtime_WorkflowTerminated;
        }
    }

None of the events are triggered which only goes to say that the way I'm referencing the runtime instance in this particular scenario is wrong.

Anyone know of a way to do this? Thanks in advance.


The WorkflowRuntime and WorkflowRuntimeBehavior are WF3 artifacts but your question is tagged as WF4 so I will presume you are using WF4.

In WF4 the way to do this is by using a custom TrackingParticipant and adding that to the WorkflowExtensions collection of the WorkflowServiceHost.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜