Do your UI updates on the main thread and find some other way of communicating what the UI thread needs to update itself. i.e. decouple your UI from the data it visualises.<br><br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-NZ" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">PreloadSong;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">WaitForEngine; // does a LoopSleep<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">SetCuePosition;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">WaitForEngine;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">StartPlay;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">etc.</span></p>
</div></div></blockquote><div><br></div><div>Do this in a worker thread then your UI can continue to update on the main thread without having to worry about anything else. You're right that the VCL isn't thread safe, but it's easier to make your data sources thread safe so that the VCL main thread can access them safely along with any worker threads, than it is to try to make the main VCL thread behave as if it were effectively multiple threads (which is what you are trying to do by having it do work, update the UI AND pump the message queue).<br>
<br>Also, the fact that your routine is called "WaitForEngine" suggests to me that an event would be ideal in your situation. If accurately named, that routine indicates that your worker thread is waiting for some signal that the engine is ready, a signal that the engine can send directly using an event (i.e. a TEvent - a thread synchronisation object, not a TNotifyEvent or similar), rather than using a busy-wait loop.<br>
<br>It may not be a solution as quick and easy as throwing in a call to Application.ProcessMessages, but I am pretty confident that it will absolutely be more robust in the long run.</div><div><br>At least, that's the way I'd tackle this problem.<br>
<br>:)</div></div>