Timers

  • Thread starter Thread starter Derek Hart
  • Start date Start date
D

Derek Hart

I am running a winforms app as a windows service on Windows 2008 server. I
have a timer that checks a database flag every 5 seconds. I want to limit
the number of times the timer can run, by keeping track of how many are
running. What is the best way to do this? Store this in a sql database
table. Just check the value in the database and increment or decrement,
while stopping the timer at the max value? Will that be reliable? Store in a
plain old global variable inside the service?
 
You could use any of these mechanism. The simplest, I'd think, would be a
private variable inside the object that you create to execute you DB access,
with the decrement or increment and test. You then could create a property
to access that variable to adjust the limit at runtime (if necessary).

Dick

--
Richard Grier, Consultant, Hard & Software 12962 West Louisiana Avenue
Lakewood, CO 80228 303-986-2179 (voice) Homepage: www.hardandsoftware.net
Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004, Revised July
2006.
 
Back
Top