Communication between modules

Topics: CAB & Smart Client Software Factory
Aug 18, 2011 at 6:51 PM

I have module A that want to open a view in module B with a given parameter. I know I can do this with events but is there other options ?

I think if I make the workitem in module B a child of workitem in module A I can do it directly since I have "access" to the definition of the view (the Type).

Aug 19, 2011 at 6:10 PM

Hi,

Using events to communicate between modules to perform an action (in this case, showing a view) seems to be valid approach to achieve your requirement. However, if you don't want to use events another possible approach would be to communicate between modules using a service that would be shared across your modules.

For information about how to this you can check the following topic on MSDN:

I hope you find this useful,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Aug 19, 2011 at 6:19 PM

Thanks I will investigate into services soon. Right now I have an event A so the second module can listen to. When the second module is "done" it raises another event so the first module know it's finished.

Example : Module A needs a customer being selected which is taken care by module B. Module A raise event "SelectCustomer". Module B listen, process and then raise event "CustomerIsSelected"

It works with events...but i'm sure services would be more elegant or maybe ActionCatalog which I have yet to look at

Aug 23, 2011 at 5:57 PM

I just created a service in module B and I added it to the RootworkItem. That way, module A can get a reference to it with the Get<> method. Now, how is the service suppose to be able to show a view ? It doesn't have access to the workitem nor the workspaces...

Aug 24, 2011 at 5:29 PM

Hi,

As an approach to show the view you can use the service as a means to notify that the view must be shown. For example, the module A could modify a property in the service and when the module B detects that the property has changed (e.g. subscribing to an event published by the service) show the view. This way the service doesn't need to know how to show a view, and is only used as a way to communicate between modules.

I hope you find this useful,

Damian Cherubini
http://blogs.southworks.net/dcherubini