Timers for "larger" intervals?

P

Paul J. Hurley

I am working on an application that will repeat a certain procedure after a
user specified time interval. This interval could be as brief as 2
seconds, or as long as once every hour or two. If it was limited to
several seconds or even every few minutes, I would use one of the timer
classes, probably System.Threading.Timer. But I don't know if it's good
practice to allocate a Timer for something as long as a couple of hours. I
know the System.Windows.Forms.Timer has limitations on the interval, but I
can't find any such limits in any of the Threading timers doco.

Is it OK to use a System.Threading.Timer for an hourly interval?

Thanks
Paul
 
I

Imran Koradia

System.Windows.Forms.Timer takes in an Integer value as the interval
represented in milliseconds. With the positive integer values ranging from 1
to 2^32 - 1, you actually have an upper limit of approximately 596.5 hours.
With System.Threading.Timer, one of the constructor takes in longs as well
which gives you an even higher limit. So, as such you shouldn't have to
bother about the upper limit of the timer. Ofcourse, the question is whether
it would make sense to use a timer. Is this a windows app or a console app?
you could make it a console app and schedule it via the windows scheduler
which is probably a good idea if you shouldn't have trouble converting it to
a console app. If not, I cannot think of any reason why a large interval
wouldn't work.

hope that helps..
Imran.
 
P

Paul J. Hurley

Thanks for the tips, Imran. My app is a data acquisition Windows app. It
periodically checks an external device (or devices) and records, compares,
crunches, etc. the relevant data. The Windows Scheduler would do what I
need, but since I'm not creating a console app I guess it's not an
appropriate choice.

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top