<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 09/15/2014 02:19 PM, Xiangrong Fang
wrote:<br>
</div>
<blockquote
cite="mid:CAP93jB3Xo6B20_G32bLLxADxgnZ0xWW6YtPnCJq52w0jPgKnYQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_default" style="font-family:'courier
new',monospace"><span style="font-family:arial">2014-09-15
17:23 GMT+08:00 Michael Schnell </span><span dir="ltr"
style="font-family:arial"><<a moz-do-not-send="true"
href="mailto:mschnell@lumino.de" target="_blank">mschnell@lumino.de</a>></span><span
style="font-family:arial">:</span><br>
</div>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> <br>
In that case I definitely would use
Application.QueuAsyncCall.</div>
</blockquote>
<div><br>
</div>
<div class="gmail_default" style="font-family:'courier
new',monospace">If I understand correct, from this page:</div>
<div class="gmail_default" style="font-family:'courier
new',monospace"><br>
</div>
<div class="gmail_default" style=""><font face="courier new,
monospace"><a moz-do-not-send="true"
href="http://wiki.freepascal.org/Asynchronous_Calls">http://wiki.freepascal.org/Asynchronous_Calls</a></font><br>
</div>
<div class="gmail_default" style=""><font face="courier new,
monospace"><br>
</font></div>
<div class="gmail_default" style=""><font face="courier new,
monospace">QueueAsyncCall is, like what its name
suggest, doing this in asynchronous favor -- it execute
queued method in the next message loop (while
Application.ProcessMessages takes place, right?).</font></div>
</div>
</div>
</div>
</blockquote>
<font face="courier new, monospace"><br>
That is </font>exactly what Postmessage does (in combination with
procedure ... message). <br>
<br>
In fact you don't need to call <font face="courier new, monospace">Application.ProcessMessages
</font>(on that behalf). In fact (usually) the main thread is not
supposed to do long lasting or even polling loops to be made of
run-to-completion events. <font face="courier new, monospace">QueueAsyncCall
just schedules another run-to-completion event for you and same
will automatically happen as soon as the main thread is free (having
done all previously scheduled events). <br>
</font><br>
<blockquote
cite="mid:CAP93jB3Xo6B20_G32bLLxADxgnZ0xWW6YtPnCJq52w0jPgKnYQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div class="gmail_default" style=""><font face="courier new,
monospace"><br>
</font></div>
<div class="gmail_default" style=""><font face="courier new,
monospace">But what I need PostMessage for is to notify
main thread (or another thread) that a worker thread
finished its job, so that the thread manager can start a
new thread to do the remaining work.</font></div>
</div>
</div>
</div>
</blockquote>
<font face="courier new, monospace">Neither </font><font
face="courier new, monospace">QueueAsyncCall nor </font>Postmessage
have anything to do with finishing a thread (unless you call it
right before the end of the thread's execute procedure).<br>
<blockquote
cite="mid:CAP93jB3Xo6B20_G32bLLxADxgnZ0xWW6YtPnCJq52w0jPgKnYQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div class="gmail_default" style=""><font face="courier new,
monospace"><br>
</font></div>
<div class="gmail_default" style=""><font face="courier new,
monospace">Anyway, is PostMessage considered
"deprecated" or "shall be used on windows only"? </font></div>
</div>
</div>
</div>
</blockquote>
<font face="courier new, monospace">Not really depreciated </font>but
IMHO <font face="courier new, monospace"> (when used for thread to
main thread signaling) </font>it's a relict from Delphi's
widows-only heritage. <br>
<blockquote
cite="mid:CAP93jB3Xo6B20_G32bLLxADxgnZ0xWW6YtPnCJq52w0jPgKnYQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div class="gmail_default" style=""><font face="courier new,
monospace">Is there a better way to do what I want?</font></div>
</div>
</div>
</div>
</blockquote>
<font face="courier new, monospace">As said: you can do </font><font
face="courier new, monospace">Application.QueueAsyncCall() </font><font
face="courier new, monospace">right before the end of the thread's
execute procedure;<br>
<br>
(Or you can simply start the new worker thread there instead of
having the main thread do this if this might be appropriate.)<br>
<br>
-Michael </font><br>
<br>
</body>
</html>