views:

28

answers:

1

Hi all,

Thanks for taking time to read this question.

I am designing a 3-tier solution written in c# that needs to carry out processing every minute. The processing should be initiated at the same time from different unconnected parts of the program.

What's the best way to implement a system-wide timer? Should it be in the business logic layer or UI layer? What kind of timer is best, e.g. one from System.Forms of from System.Threading, or? Is there a rule of thumb for this situation?

Many thanks

+1  A: 

I would say have a static or singleton class in your business layer expose an event, that can be subscribed to by everyone else in the application.

I would use System.Threading.Timer, which uses its own thread. System.Windows.Forms, conversely, is meant to be used inside a control (and I think runs in the UI thread).

Mau
I agree. System.Threading.Timer should be used (and it ticks off in it's own thread) - and that timer event shoudl then raise some static events, which other components could subscribe to.
Robert Seder
Thanks. I need to look into static events, I wasn't sure you could have these. Thanks.