Re: Intermittent work in UI thread
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Mon, 15 Oct 2007 15:58:35 -0400
Use WM_TIMER. Every 60,000 ms you process a timer message that starts the process. If
the process is paused, you kill the timer; if it is started again, restart the timer:
UWM_START_WATCHING: SetTimer(60000, IDT_WATCHER, NULL);
UWM_STOP_WATCHING: KillTimer(IDT_WATCHER);
WM_TIMER: for IDT_WATCHER, do DB query processing, updates
Note that no aspect of this thread will touch any window.
IDT_WATCHER is some value you invent to designate the timer
joe
On Mon, 15 Oct 2007 19:43:10 +0100, Pedro Ferreira <none@xxxxxxxx> wrote:
Hi,Joseph M. Newcomer [MVP]
I'm trying to create a UI thread to do constant background work, but I'm
having some design problems.
The thread needs to fetch records from a database. do some processing on
each record and, when there are no more records, sleep for 1 minute
before check the database again. The process will be controlled with
thread messages (to start, pause, query...).
My problem is where should I put the processing work. I need it to be
responsive between cycles, where the process waits for 1 minute, so I
can stop it in that period. My only idea is using OnIdle to do the work.
But then, how should I make it real idle when waiting for 1 minute?
Could anyone give some hints on what is the way to go?
Thanks
Pedro Ferreira
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Intermittent work in UI thread
- From: Pedro Ferreira
- Re: Intermittent work in UI thread
- References:
- Intermittent work in UI thread
- From: Pedro Ferreira
- Intermittent work in UI thread
- Prev by Date: Re: This calculation is just wrong / computer can't count!
- Next by Date: Re: Wrapping of a String
- Previous by thread: Re: Intermittent work in UI thread
- Next by thread: Re: Intermittent work in UI thread
- Index(es):
Relevant Pages
|