Is there any way to invoke methods in different modules

Oct 5, 2008 at 5:24 AM
I'm looking forward to use Prism, but I have a question.

For example I have ModuleA, and ModuleB.

I want to invoke MethodB from ModuleA.  Is there any way to do it?
Oct 6, 2008 at 3:01 PM

Hi,

 

One possible approach would be to use the Event Aggregator. However, you must keep in mind that a published event may be captured by more than one subscriber (if there are more than one instance of the subscriber class) and there can be also more than one publisher for an event.

For an example, you may have a look at the Event Aggregation QuickStart.

For more information, you may check the following topics:

·         Event Aggregator

·         How to: Create and Publish Events

·         How to: Subscribe and Unsubscribe to Events

 

Another possible approach would be to declare an interface for the class (whose methods you want to invoke) in a common module (referenced by Module A and Module B) and then register an instance of that class in the container (e.g.: in Module A), so that the other module (e.g.: in Module B) can retrieve it through its interface and invoke its methods.

 

You may also use services for the same purpose.

 

Hope it helps.

 

Ignacio Baumann Fonay

http://blogs.southworks.net/ibaumann/