views:

17

answers:

2

Supose that I have a flowchat with a receive, custom code activity and sendreply and the custom code activity throws an exceptions. How can I return to the receive activity?

Any ideas?

+1  A: 

You could use the "While" activity as a means of retrying - should there be an exception.

alt text

The entire article with more details for this sample is here

InSane
The article is all about WF3 not WF4 which is a completely different product. The same basic principals apply though, just not the technical details.
Maurice
Agreed. However, the pattern is pretty general and so are the activities used so i thought it might be useful
InSane
A: 

I created a custom activity in a similar way of the article with wf4, its something like this:

public sealed class Retry : NativeActivity {

    public Activity Body { get; set; }

    protected override void Execute(NativeActivityContext context) {
        context.ScheduleActivity(Body, OnBodyCompleted, OnBodyFaulted);
    }

    void OnBodyCompleted(NativeActivityContext context, ActivityInstance instance) {

    }

    void OnBodyFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom) {
        faultContext.ScheduleActivity(Body, OnBodyCompleted, OnBodyFaulted);
    }
}

Thanks!

Murilo Lima