Using Timers in a composite application

Nov 18, 2008 at 3:39 PM

Is there a recommended place to place timers which simply perform background activities whilst the application is idle? Should I put this in the shell or one of the views or modules? Or does it not really matter
Nov 18, 2008 at 8:07 PM



A possible place to add Timers is inside a common service. This service should have an interface to expose the Timer functionality and its implementation could be placed, for example, in an Infrastructure project. As the services are singletons, you will always get the same Timer instance. The common services are usually registered in the container in your Bootstrapper class to make it available through all the application.

For more information related to services and container you can review the following topics in the documentation:

·         Container

·         Container and Services


If you want perform a background activity in response to a user event, you may consider using the Event Aggregator service. This service allows you to subscribe to events in a background thread using the ThreadOption.BackgroundThread option:

MyEvent myEvent = eventAggregator.GetEvent<MyEvent>()

myEvent.Subscribe(MyEventHandler, ThreadOption.BackgroundThread);


For more information related to the Event Aggregator service check the following topics in the documentation:

·         Event Aggregator

·         How to: Subscribe and Unsubscribe to Events

·         How to: Create and Publish Events


Please let me know if this helps.


Mariano Converti

Nov 18, 2008 at 8:58 PM
Thanks Mariano

Actually I should have put more context in the original thread sorry. The actual timer funtionality is required due to using WF in the application.



Does this advice still apply in this case then?