public class NativeActivity1 : NativeActivity
{
public NativeActivity1()
{
var myDynamicActivity = ActivityXamlServices.Load(@"C:\WorkflowConsoleApplication1\WorkflowConsoleApplication1\Workflow1.xaml") as DynamicActivity;
var argInt32 = new InOutArgument<int>();
this.ChildActivity = new DynamicActivity
{
Properties = { new DynamicActivityProperty() { Name="argInt32", Type=typeof(InOutArgument<int>), Value=argInt32 }, },
Implementation =() => new Sequence
{
Activities =
{
myDynamicActivity,
new WriteLine { Text = new InArgument<string>(ctx => argInt32.Get(ctx).ToString()) }
}
}
};
}
public DynamicActivity ChildActivity { get; set; }
protected override void Execute(NativeActivityContext context)
{
var parameter = 10;
while (0 < parameter--)
{
var activityInstance = context.ScheduleDelegate(
new ActivityAction { Handler = this.ChildActivity }
, new Dictionary<string, object> { { "argInt32", parameter } }
, (activityContext, completedInstance, outArguments) =>
{
Console.WriteLine("Output:" + outArguments["argInt32"].ToString());
}, (faultContext, propagatedException, propagatedFrom) =>
{
Console.WriteLine("Fault");
});
}
}
}
class Program
{
static void Main(string[] args)
{
WorkflowInvoker.Invoke(new NativeActivity1());
Console.WriteLine("Press any key to end the process ...");
Console.ReadLine();
}
}
1에서 10까지의 반복을 만드는 while 루프가 있습니다. 모든 증분 값이 워크 플로에 전달되고 워크 플로는 -1을 곱하여 음수 값을 반환한다고 가정합니다. Execute 메서드를 유지하고 반복을 수행해야하므로 매개 변수가있는 워크 플로를 호출하는 유일한 방법은 NativeActivityContext.ScheduleDelegate를 사용하는 것입니다. 프로그램의 유일한 제한은 WorkflowInvoker.Invoke를 사용하지 않는 것입니다. 누군가가 ScheduleDelegate를 사용하는 방법을 알고 있습니까?WF4 - NativeActivityContext.ScheduleDelegate를 호출하는 올바른 방법은 무엇입니까?
감사합니다, Moiz
여기서 무엇을하려고하는지 잘 모르겠습니다. 당신은 인자가없는 DynamicActivity를 호출하고 있고, 입력 인자를 가진 변수 만 호출하고 있습니다. – Maurice
모리스, 제 질문을 업데이트했습니다. 답을 알고 있으면 게시하십시오. – Moiz