Statemachine and Data

Mar 28, 2013 at 12:25 PM

I have a basic question to StateMachines in WF4.
How is it possible to pass data to the StateMachine?
This is from the WaitForNotificationExtension.cs from Rjacobs:
protected void RaiseNotification(TNotification notification, TValue data)
            // Ignore if the workflow instance is not set yet
            if (this.workflowInstanceProxy == null)

            // If a bookmark is pending for this notification resume it
                new Bookmark(notification.ToString()),
                (asr) =>
                    // If the bookmark cannot be resumed, queue the event
                    if (this.workflowInstanceProxy.EndResumeBookmark(asr) != BookmarkResumptionResult.Success)
                        this.QueueNotification(notification, data);
When I debug into this, I see that the "data" is sent, but I don't know how this "data" has to be.
I tried it with a Dictionary<string, object>, where my String is the InArgument of my CodeActivity. But this was alway null.
Now my question(s):
  • Can I pass data in the StateMachine.Explicit Example from Ron Jacobs?
  • In which Entity can I pass data? Transition, State oder CodeActivity?
  • How has this data to be built?
Thanks in advance.

Apr 3, 2013 at 12:38 PM
I can answer my own question for posterity.
The WaitForNotificationBase Class has a Result, which is correctly written with my data.
And here comes the general part on how to bring data from one Activity to another:
  • SourceActivity: write Data in Result (this is a normal OutArgument)
  • In Destination create a variable (eg MyVariable) which has to have the same type as the OutArgument of Source
  • Assign: InArgument = MyVariable (this sounds pretty weird, but it really has to be this way)
Look here for further info from Guru of Workflow: