<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
You may also want to take a look at the PostThreadMessage API, which
you can use to signal from a thread back to the main thread or vice
versa<br>
<br>
HTH<br>
<br>
David<br>
<br>
<br>
<br>
On 15/05/12 18:53, Jolyon Smith wrote:
<blockquote
cite="mid:CALXexOoGhYq7AddUYHg8ds96AK-dcXTFjje+T3jsr+p+_Jx3YA@mail.gmail.com"
type="cite">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 link="blue" vlink="purple" lang="EN-NZ">
<div>
<p class="MsoNormal"><span
style="font-family:"Calibri","sans-serif";color:#1f497d">PreloadSong;</span></p>
<p class="MsoNormal"><span
style="font-family:"Calibri","sans-serif";color:#1f497d">WaitForEngine;
// does a LoopSleep</span></p>
<p class="MsoNormal"><span
style="font-family:"Calibri","sans-serif";color:#1f497d">SetCuePosition;</span></p>
<p class="MsoNormal"><span
style="font-family:"Calibri","sans-serif";color:#1f497d">WaitForEngine;</span></p>
<p class="MsoNormal"><span
style="font-family:"Calibri","sans-serif";color:#1f497d">StartPlay;</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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: <a class="moz-txt-link-abbreviated" href="mailto:delphi@listserver.123.net.nz">delphi@listserver.123.net.nz</a>
Admin: <a class="moz-txt-link-freetext" href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a>
Unsubscribe: send an email to <a class="moz-txt-link-abbreviated" href="mailto:delphi-request@listserver.123.net.nz">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe</pre>
</blockquote>
<br>
</body>
</html>