I think OP's use of the timer is really more minimal than it looks. He just
right) then do that. Looks like the check doesn't need to be done while
be stopped during that operation.
no reason to stop it once it's running. It could just send a user message
pretty easily in the UI thread.
Still, for something this simple, the timer idea works OK.
On Apr 29, 1:55 pm, Simon <b...@example.com> wrote:
Pause: no, you can only kill it and set it again.
Remaining time: no way that I know of, so you will need to create a
mechanic of your own. It's not hard (e.g. remember time of last
WM_TIMER and then do long remaining = (lastTick+PERIOD)-Now()).
I see what you are saying.
I might do something like that.
What are you trying to achieve?
Yes, I am fairly sure I need it.
We have some use cases to 'pause', (or delay), a timer.
Here is a common example.
We have a server application, when it starts, it checks online for new
transactions every 10 minutes.
During those 10 minutes the user can start a time consuming process,
(printing of reports, connecting to another app, doing a backup), during
the process we do not want to check for transactions.
What I could do is:
OnTimer()
{
if( busy_doing_something_important )
{
// check again in 10 seconds
}
else
{
check_for_transactions()
}
}
Well, your example absolutely begs the question: what's wrong with
doing "check_for_transactions()" in another thread? (IOW, if this is
your situation, then who cares about a timer!? Spawn a thread for
either, or even both operations. Sure, first rule of multithreading is
"don't", but if you have anything on the lines of a long-running
procedure, that rule easily rules itself out.
Goran.