Topics: Prism v4 - WPF 4
Dec 20, 2010 at 10:18 AM


I'm new in Prism v4  and I would like to know: is it poslible to create aplicaton that will actvate and execute commands in some of my modules without clicking on them.

For example, if I have simple application that has one button, which when is pressed some message will be shown. Can I create application that when it's started I can see complete  UI

and then create new thread that will execute commands that I want to see working?



Dec 20, 2010 at 4:51 PM
Edited Dec 20, 2010 at 4:51 PM

Hi Drasko,

I'm glad to see that you've started using Prism. The requirement that you're mentioning is possible. If by command you're referring generically to any kind of action, you can use for example the Event Aggregator, which provides a means to publish and subscribe to events from different loosely coupled components (for example, different modules that reside on a separate assembly). Using the Event Aggregator, there is an option to specify that you want to receive your event in a background thread. From the documentation, "BackgroundThread. Use this setting to asynchronously receive the event on a .NET Framework thread-pool thread." You can read more about Event Aggregation (as well as other means of communication between loosely coupled components) in this chapter from the Prism MSDN documentation.

If you specifically mean that you need to execute an ICommand (such as a RoutedCommand, a DelegateCommand or a CompositeCommand) responding to an action that isn't clicking a button, you might find one of following articles useful:

You can also read more about commanding in Prism v4 in the aforementioned chapter from the MSDN documentation.

I hope you find this helpful.

Guido Leandro Maliandi