about my last sentence....lol I know...
what i meant was i just set the timer to 30 seconds while testing the
threading
so i can make sure all is running correctly, stored procs , processing,
updating etc
now i need to re think the timers on running the way they need to run
1 time once a week at a given time....
I thank you very much for your time and effort
DaveP
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Sat, 14 Jun 2008 17:36:41 -0700, daveL <ve***********@yahoo.comwrote:
Im not explaining myself well , because im unsure how to approach this
so do i set the interval to x amount of milliseconds based on
milliseconds
in a 24 hour period
then check if its the day i want
You could. But why not just set the interval to the number of
milliseconds in a week?
also if time to run is involved do i set the timer to lets say hourly and
how to make it precise on the time required to run
How precise do you need it to be?
It seems to me your best bet is to determine the exact time in the future
you want the timer to execute, calculate the difference between that exact
time and "now", and then use the result of that as the timer delay for a
one-shot timer.
Elapsed time calculation might look like:
DateTime dtEvent = /* initialized to some specific date/time */
TimeSpan tsDelay = dtEvent - DateTime.Now;
Then the milliseconds are "tsDelay.TotalMilliseconds". Assuming you're
using a timer that requires setting in milliseconds, set this for the
elapsed time for the timer and start the timer. It will fire when the
elapsed time has expired. (Obviously for a timer class that accepts a
TimeSpan value, you don't need to use the TotalMilliseconds property to
convert to milliseconds :) ).
Each timer class has a slightly different syntax for configuring it as a
one-shot timer, so without knowing what class you're using, it's not
possible to say for sure what you would want to do. But, for example, the
System.Timers.Timer class has an AutoReset property which, when set to
false, causes the timer to fire just once. It won't fire again until you
specifically start it again.
Finally, a week is a long time. Obviously you may want to include some
means of re-enabling the timer in case your process exits and is restarted
before the timer fires. This is just a special case of the above
calculation, where the "specific date/time" is the same as it was before,
but of course DateTime.Now returns a new value. :)
the thread is running perfect i just dont have it running like i need
yet....
No offense intended, but that sentence seems self-contradictory. :)
Pete