Re: Intermittent work in UI thread



"Pedro Ferreira" <none@xxxxxxxx> wrote in message
news:eM5xAr1DIHA.2004@xxxxxxxxxxxxxxxxxxxxxxx
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?


I would create a worker thread (not a UI thread) unless you need a UI thread
for some specific purpose not apparent in this description. The worker
thread would do it's work and then do a WaitForSingleObject() with a timeout
of 1 minute (60000 ms), which causes WaitForSingleObject() to return when
either the main thread sets an event for starting, pausing, querying, etc.
or the 1 minute has elapsed. If you need separate events each for starting,
pausing, querying, etc. use WaitForMultipleObjects() instead of
WaitForSingleObject().

-- David


.



Relevant Pages

  • Re: Intermittent work in UI thread
    ... having some design problems. ... The thread needs to fetch records from a database. ... I would create a worker thread unless you need a UI thread ... thread would do it's work and then do a WaitForSingleObject() with a timeout ...
    (microsoft.public.vc.mfc)
  • Re: Access 97 to a more powerfull platform!?
    ... Moving to SQL Server is common when a database "outgrows" ... Design problems are far and away the usual reason why a database ...
    (microsoft.public.access.gettingstarted)
  • Intermittent work in UI thread
    ... 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. ...
    (microsoft.public.vc.mfc)
  • Re: Intermittent work in UI thread
    ... for some kinds of interfacing require a message pump to deal with event handling. ... On-Anything handlers involved in the database interface, then a UI thread is required. ... thread would do it's work and then do a WaitForSingleObject() with a timeout ...
    (microsoft.public.vc.mfc)

Loading