I want to stop processing a Sequential workflow if an activity fails....
How do I force it to stop processing everything else?
Any help would be appreciated.
Thanks
How do I force it to stop processing everything else?
Any help would be appreciated.
Thanks
Your question does not say how the 'failure' is manifested in the workflow - is it a return value or an exception?
If it's an exception you would add a FaultHandlerActivity in the Fault Handlers View of your workflow. Set the exception type to the expected type of exception and add a Terminate activity to it.
If it's just an invalid/error return value, then you could just write code to cancel the workflow, or a nicer way would be to throw your own exception, and let the FaultHandler pick it up and terminate.
Can you tell me where to go to find information on how to set up a FaultHandler?
I see it the designer, I just want to make sure I set it all correctly.
Thanks.
Take a look at Mike Taulty's excellent screencast 'nuggets'
http://wf.netfx3.com/files/folders/screencasts/entry4975.aspx
This one shows how to handle exceptions for either the whole workflow, or a localised exception for just particular sequence.
However, I added a Fault Handler to the SequenceActivity and it's writing out the log entry that an exception occured according to the CodeActivity I defined. But it's not stopping the workflow.
I have a WhileActivity.. Should I place the Fault Handler there instead to stop the While from continuing?
Thanks for all your help!
I am currently calling
throw ApplicationException("Application Exeception occured"); inside my ifElseBranchActivity Event for Failure.
and then using the FaultHandler inside the Sequence Activity to catch the ApplicationException.
but It doesn't stop the it from running other Activities in that same workflow, I guess since it's inside the WhileActivity.