[DUG] Why does this hang?

Paul Heinz paul at accredo.co.nz
Tue Aug 2 16:03:40 NZST 2011


Hi Ross 

> I can't remember now what problem I was having with 
> Application.ProcessMessages but this code fixed it while I 
> was testing, and had to find tune the message numbers.  I 
> failed to comment the code.  I think it had something to do 
> with other visible non-modal forms.
> 
> I may have to re-instate ProcessMessages and see what the problem was.
> 
> The wait loop is generally no more than 2 or 3 seconds 
> waiting for a thread command to finish, but I need the main 
> window to update continuously during this time.

Hrmm.. I don't really understand the architecture of your app, but
_usually_ threads are an attempt to NOT have to have blocking busy-wait
loops in your main UI thrad. Could your worker thread not send a message
(or use Thread.Synchronise which sends a message for you) to signal it's
completion instead?

In short, why can't you just return to the normal message loop? 

It sounds like your application has some of behaviour mode that depends
on the thread completion state but that might be better handled in the
message event handlers themselves thus completely decoupled from the
message loop itself.

Finally, it's more of a side issue but the timers you speak off which
are updating the UI - are they able to be handled as idle time events
instead or are they actually indicating timing related information to
the user?

Cheers,
  Paul.





More information about the Delphi mailing list