Re: Intermittent work in UI thread

Tech-Archive recommends: Fix windows errors by optimizing your registry



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,

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
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: displaying non modal dialog for a short period of time
    ... Start a timer when your dialog opens, ... Intercept the timer message in your dialog. ... close up shop. ... Prev by Date: ...
    (microsoft.public.vc.mfc)
  • Re: Multiple Timers
    ... I tend to only use one timer and have a list of timer events. ... On each timer message I go down the list and trigger yhose events needing action. ... The xml file fills an array of struct (Lets' call ...
    (microsoft.public.vc.mfc)
  • Re: How to run immediately?
    ... don't try to send a timer message. ... the WFSO should have a timeout ... The thread will then trigger itself, ...
    (microsoft.public.vc.mfc)
  • Re: Close Access, or Timer/Timer Event Help
    ... opening the database, I like the KISS method, when I can use it! ... So your method of adding Exit to your macro would probably work. ... You need to set the form's Timer ... Private Sub Form_Timer ...
    (microsoft.public.access.modulesdaovba)
  • Re: Question about Re-Linking Tables from Backend
    ... Your code seems to be going into a pausing loop and then closes the form. ... Use the form's Timer event to run the relinking code. ... to 10 milliseconds in one of my database files. ...
    (microsoft.public.access.devtoolkits)