Async workflow try/catch block not working as expected
Hi all, I have a workflow I run asynchronously that sort of (very simplified) looks like this:
try {
foreach(feature in myFeatures) {
try {
doStuff(feature)
}catch(Exception ex) {
}
}
}catch (Exception ex) {
}
the idea being, if
doStuff(feature)
throws an exception, I catch that exception, handle it in the inner catch block (logging etc.), and then continue the foreach loop with the next feature.Unfortunately, although I do catch the exception in the inner catch block, the loop does not continue and my workflow goes to the outer catch block and terminates. I am not (re)throwing the exception, so why does that happen?
I think this was working correctly when I ran my workflow normally instead of via an Invoke Workflow Async activity (from a different workflow), which just makes this even stranger...
Anyone know what's going on here?
0
-
Hi Nik
I suspect this is to do with the fact that the workflow is being run asynchronously. Can you confirm if you see the same issue calling the workflow normally?
A potential workaround would be to break out the inner loop into it's own workflow, so each instance can succeed/fail without bringing down the whole caller.
Thanks
Gareth0
Please sign in to leave a comment.
Comments
1 comment