Hello someone who I have never met before and just happens to share my IP.
You're doing something wrong. Elsewhere, that is.
Either the DLL with the activities you're using isn't fresh, or the workflow definition is out of date and doesn't hold what you believe it does. Or its something completely different.
I've stripped down your code and compressed it into a sample project. Like to see it here we go:
This is the simple condition:
public sealed class AnTrigger : NativeActivity<bool>
{
public bool ResultToSet { get; set; }
protected override void Execute(NativeActivityContext context)
{
Result.Set(context, ResultToSet);
}
}
Simple, no? Here's the host that evaluates this condition and, if it returns true, runs a single child activity. Note, I'm constructing the activity in the Create method so I don't have to create an editor.
public sealed class AnTriggerHost : NativeActivity, IActivityTemplateFactory
{
public ActivityFunc<bool> Condition { get; set; }
public ActivityAction Child { get; set; }
protected override void Execute(NativeActivityContext context)
{
context.ScheduleFunc(Condition, OnConditionComplete);
}
private void OnConditionComplete(
NativeActivityContext context,
ActivityInstance completedInstance,
bool result)
{
if (result)
context.ScheduleAction(Child);
}
Activity IActivityTemplateFactory.Create(System.Windows.DependencyObject target)
{
// so I don't have to create UI for these, here's a couple samples
// seq is the first child and will run as the first AnTrigger is configured to return true
// so the first trigger evals to true and the first child runs, which
var seq = new Sequence
{
DisplayName = "Chief Runs After First Trigger Evals True"
};
// prints this message to the console and
seq.Activities.Add(new WriteLine { Text = "See this? It worked." });
// runs this second trigger host, which
seq.Activities.Add(
new AnTriggerHost
{
DisplayName = "This is the SECOND host",
Condition = new ActivityFunc<bool>
{
// will NOT be triggered, so you will never see
Handler = new AnTrigger
{
ResultToSet = false,
DisplayName = "I return false guize"
}
},
Child = new ActivityAction
{
// this activity write to the console.
Handler = new WriteLine
{
Text = "you won't see me"
}
}
});
return new AnTriggerHost
{
DisplayName = "This is the FIRST host",
Condition = new ActivityFunc<bool>
{
Handler = new AnTrigger
{
ResultToSet = true,
DisplayName = "I return true!"
}
},
Child = new ActivityAction
{
Handler = seq
}
};
}
}
Drop these two in a Workflow Console app and drop the AnTriggerHost on the workflow. Set ye a couple breakpoints and watch it fly. Here's the workflow xaml:
<local:AnTriggerHost DisplayName="This is the FIRST host" >
<local:AnTriggerHost.Child>
<ActivityAction>
<Sequence DisplayName="Chief Runs After First Trigger Evals True">
<WriteLine Text="See this? It worked." />
<local:AnTriggerHost DisplayName="This is the SECOND host">
<local:AnTriggerHost.Child>
<ActivityAction>
<WriteLine Text="you won't see me" />
</ActivityAction>
</local:AnTriggerHost.Child>
<local:AnTriggerHost.Condition>
<ActivityFunc x:TypeArguments="x:Boolean">
<local:AnTrigger DisplayName="I return false guize" ResultToSet="False" />
</ActivityFunc>
</local:AnTriggerHost.Condition>
</local:AnTriggerHost>
</Sequence>
</ActivityAction>
</local:AnTriggerHost.Child>
<local:AnTriggerHost.Condition>
<ActivityFunc x:TypeArguments="x:Boolean">
<local:AnTrigger DisplayName="I return true!" ResultToSet="True" />
</ActivityFunc>
</local:AnTriggerHost.Condition>
</local:AnTriggerHost>
Your issue doesn't lie in the activities, it lies in how you're using them. You're assuming your test rig is correct when it isn't.