Tuesday, March 03, 2009

I talked about the new WF4 Runtime model a while back. One of the things I discussed was the new data flow model of arguments and variables. However, if you are used to WF 3.5 something looks a bit odd here. Lets look at a simple activity example:

public class WriteLineActivity : WorkflowElement
{
    public InArgument<string> Text { get; set; }
    protected override void Execute(ActivityExecutionContext context)
    {
        Console.WriteLine(Text.Get(context));
    }
}

Why do I need to pass the ActivityExecutionContext when I want to get the data from the argument? This highlights a subtlety to the change in the runtime model. The activity is really just a template. A class called ActivityInstance is the thing that is actually executed, it just has a reference to the actual activity to be able to hand off to the activty’s methods (e.g. Execute). The actual argument state is stored in a construct called the LocalEnvironment. The ActivityExecutionContext gives access to  the current ActivityInstance and that in turn holds a reference to the current LocalEnvironment. Therefore, to get from  an activity’s Execute method to its state we have to go via the ActivityExecutionContext.

 | 
Tuesday, March 03, 2009 8:41:42 AM (GMT Standard Time, UTC+00:00)  #    Comments [1]TrackbackTracked by:
"NativeActivity – A Tricky Beast" (.NET Meanderings) [Trackback]
http://www.dotnetconsult.co.uk/weblog2/PermaLink,guid,c3394709-1aaf-486a-8d1f-51... [Pingback]
Monday, March 16, 2009 3:15:25 AM (GMT Standard Time, UTC+00:00)
This puzzled me for a while, now it's clear.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):