I have just started wrapping my head around WF4; and I'm struggling to understand why my outputs are blank within my workflow.
First, I have an .xaml that contains a Sequence object (or Activity?); which in turn contains a "FirstCodeActivity", which contains the following code:
public class FirstCodeActivity : NativeActivity
{
public OutArgument<string> FirstCodeHasExecuted { get; set; }
protected override void Execute(NativeActivityContext context)
{
context.CreateBookmark("FirstBookmark", OnResumeBookmark);
}
protected override bool CanInduceIdle
{
get { r开发者_运维百科eturn true; }
}
public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
{
FirstCodeHasExecuted.Set(context, "Yes");
}
}
From my understanding, this should return the value "Yes" within the FirstCodeHasExecuted property when the bookmark is set.
When debugging, I can confirm that the bookmark event is successfully fired.
Here is my WF4 initialisation code:
var idleEvent = new AutoResetEvent(false);
var workflowApplication = new WorkflowApplication(new MyWorkFlow())
{
Idle = delegate { idleEvent.Set(); },
Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
Outputs = e.Outputs;
}
};
workflowApplication.Run();
idleEvent.WaitOne();
workflowApplication.ResumeBookmark("FirstBookmark", "Resume me!");
idleEvent.WaitOne();
My issue is that I can understand why e.Outputs returns no items within its dictionary, even though I the property is set within the FirstCodeActivity.
Am I going about this wrong? My first thoughts are that the sequence is run as a different context, and therefore doesn't contain the outputs from the FirstCodeActivity.
Any help would be appreciated.
Matt
The Outputs dictionary in the Completed callback contains the OutArguments from the workflow, not activities that execute as part of the workflow. If you want to see the result of your activity there you need to create a workflow level OutArgument and bind the FirstCodeHasExecuted to that using a VB expression.
精彩评论