Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Communicating across modules with Prism?

Tags:

c#

wpf

prism

From following the Prism documentation it says there are four ways to communicate across modules -

  • Solution commanding
  • Region context
  • Shared services
  • Event aggregation

    1. Can I just chose one of these methods and apply it for all cross-module communcation? Or should I use different methods depending on the situation?
    2. In particular, in an application Im writing at the moment I have button in one module and when the user clicks it I want to start a thread in another module. Which method of communication would I use for this situation?
like image 218
Jim_CS Avatar asked Dec 24 '11 15:12

Jim_CS


1 Answers

Ans 1: Yes, you can use a single approach all-over. Most of the times it will be easier to do it that way.

Ans 2: I recommend you use Event Aggregation to do that. That way, you have a very loose coupling between the button click and the thread execution. That way, the listening module just has to be aware of a single event no matter where it was raised from.

Since, it is a single notification and not a bunch of inter-related notifications/communications, it is better to Aggregate an event rather than creating a Shared Service.

like image 125
decyclone Avatar answered Nov 10 '22 21:11

decyclone