Communication between ChildWorkitems?

Topics: CAB & Smart Client Software Factory
Dec 1, 2006 at 1:18 AM
originally posted by: titan2040

Considering a scenario where there is a root workitem ( say, MainWorkItem ) along with several child workItems ( ChildWorkItem2, ChildWorkitem2 ... ) ,
which is a better approach to communicate between the ChildWorkitems?
1. Communicating through MainWorkItem

or

2. directly communicating with the ChildWorkitems ( like peer-peer ) ( considering that overall application model will remain static i.e. the behaviour of workitems will remain fixed )


- Thanks in Advance
Dec 1, 2006 at 3:22 AM
originally posted by: Tex47

Hi,

my recommendations are to use CAB Events / Commands or Services.
Commands are fine to make some activations at other WorkItems, unfotunaly, in standard CAB there is no possibility to use parameters in a Command Call (I have expanded the standard, so now EventArgs can be used in the Command.Execute() call).
Events are even better, because of multiple subscriptions and to transfer parameters to the subscriptber, which could be an special interface to be used to communicate between the WorkItems or other classes.
Normal I would go for Services, because of, WorkItems should be used as a container controller, not to implement additional logic. The WorkItem can add the Service to the RootWorkItem services at runtime, to make this Service only be visible when u wanted it, or just use a ServiceDependency in you class to contact the service.

Hope, that helps a little.

Kristian
Dec 13, 2006 at 10:19 PM
originally posted by: pyhavaim

I would suggest that you should use the MainWorkitem for communication
Beacause it keeps things separated, Wat if there will be another workitem, that needs to be also invoked?

So I'd suggest that use the RootWorkitem per application wide communication or use EventBroker
Dec 19, 2006 at 7:58 AM
originally posted by: DaveParker

Hi, In the situation you've given we have always used communication with the event broker via the parent.

Following a post we modified the event broker to allow the publishing of an event to only a parent - it has saved us a lot of time.

More commonly we find that we want to communicate between views in the same workitem so almost all of our events are scoped "workitem" with the workitem controller picking up any that it needs to and propogating them back to the parent.

For example: "clientselected" or something like that.

We also propogate information from the parent to the children with the "descendant" option.

hope this helps
Dave