It really needs to be running in the main thread because of the VCL updates. The VCL is not thread safe as you know. A thread could be used but it would need to Synchronize with the main thread anyway.
A pause is required in execution before the next procedure is called, so a wait timer would be complicated to program. eg. PreloadSong; WaitForEngine; // does a LoopSleep SetCuePosition; WaitForEngine; StartPlay; etc. During the WaitForEngine, I need the VU meters, elapsed time counters, etc, to continue updating. It’s working well for 4000+ users but the odd rare problem like this hang. I’ll try the processmessages again but disable the mainform and see if there are any problems. Cheers, Ross. From: [email protected] [mailto:[email protected]] On Behalf Of Jolyon Smith Sent: Tuesday, 15 May 2012 4:08 p.m. To: NZ Borland Developers Group - Delphi List Subject: Re: [DUG] Hang during Sleep For what it's worth I would say that Application.ProcessMessages is asking for trouble. It sets up your code for a re-entrancy problem that it is highly unlikely to cater for adequately (as you already found once, but user input isn't the only potential source of messages that could cause re-entrancy issues for your busy-wait loop). If anything, I think the fact that this loop is (presumably) running on the main thread in your app could be the source of your lock up issues, precisely because of the need to keep that thread happily pumping your applications message queue. What is this busy-loop used for ? Can you not devise some other mechanism to achieve the same result without having to go into a busy-wait loop and putting the message loop on heart-bypass while you do so ? Maybe a waitable timer ? Or an event ? (i.e. a "proper" thread synchronization technique, which is what this appears to be trying to achieve) Just a suggestion, Jolyon
_______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [email protected] with Subject: unsubscribe
