I am new to Workflow foundation and want to understand the purpose of ActivityAction
and ActivityFunc
and how it differs from having child activities instead.
As far as I can understand child activities may exist in some composite NativeActivity
and have to be scheduled by it. So child activities may be used by NativeActivity
as event handlers during its execution. So for example this NativeActivity may run some long running computation and schedule its child when it finishes.
ActivityAction
and ActivityFunc
(func returns a result and action does not) exist for the same purpose - to enable plugging custom handlers in the course of execution defined in the NativeActivity
. The difference is that those are strongly typed and look more like contract declared by its parent.
So I came to conclusion that the main difference is strong typing and ActivityFunc/Action may be swapped with child activities. Is my understanding wrong or am I missing something?
The main purpose of ActivityAction and ActivityFunc are that you can share data between your activity and the child ones. Most of the time you don't need to and you can just schedule a child activity and it can use InArguments to get at the data. There are some cases though, like a ParallelForEach where the parent can't just populate a Variable as each child is scheduled in parallel. In that case you want to pass the data when you schedule the child activity. And that is where the ActivityAction comes in.
In most cases you should not need to use ActivityAction and ActivityFunc though.