11 Nisan 2011 Pazartesi 06:05
I am using Sequential workflow (.net 3.5). I have created 3 custom activities and dragged these activities in my sequential workflow. The activities are
Each Custom activity will have the following execute method.
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
Inside the execute method I will write my business logic. My requirement is I have to stop the workflow instance inside the execute method based on my business logic.
How I will get the workflow instance inside the custom activity ?
How I can write something like workflowInstance.Stop() inside the execute method ?
11 Nisan 2011 Pazartesi 14:24Moderatör
You cannot get access to the WorkflowInstance from within the execute method of an activity, and even if you were able to somehow do it (static variables or something) any operations would fail because they would be invoked using the workflow thread. What you could do is to register a custom WorkflowRuntimeService with the runtime, and you could gain access to this service from within your custom activity, and tell it you wish to stop the workflow. The service would need to queue up this call on a new thread (so that it did not try to suspend a workflow using the workflow thread), and then it could signal the runtime to suspend the workflow, but it would not suspend until the current activity had completed).
I can prepare a small code example of this if required but the steps above should give you a good starting point. Please let m eknow if you need the sample code and I will be happy to create and post it here.
Steve Danielson [Microsoft]
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
02 Şubat 2012 Perşembe 17:06
I need access to the current runtime instance within my custom activity, so I would be able to subscribe handleExternalEvent activity to my custom event.
I'm not sure I totally understood what you mean, though. How can one register WorkflowRuntimeService with the runtime from within the custom activity? Can you provide any example of the stuff you mentioned above?
10 Temmuz 2012 Salı 07:57
Can you prepare a code example to show your idea in detail?
My point is to suspend flow, start another and after finish it resume first. I hope example of suspending current flow in activity would be enough for me :)