<br><br><div class="gmail_quote">On 4 October 2011 10:43, <span dir="ltr"><<a href="mailto:michael.vancanneyt@wisa.be">michael.vancanneyt@wisa.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
<br>
On Tue, 4 Oct 2011, Frank Church wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
What is the purpose of the while not Terminated in a threads execute loop?<br>
If a thread is doing its own thing and knows when or not it has finished<br>
what is the purpose of the while not Terminated<br>
<br>
Is Terminated designed to be called by other procedures besides the thread<br>
itself? Can a thread be Terminated externally?<br>
</blockquote>
<br></div>
Yes.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
This also seems to imply that if the code within the while not Terminated<br>
loop is a long running sequence a Termniate command will not be processed<br>
until control returns to the beginning of the loop<br>
</blockquote>
<br></div>
The Execute method is supposed to check Terminated at regular intervals.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Can a thread respond to a new Execute command while it already Executing? Do<br>
threads have ways of being interrogated about their state while Executing?<br>
</blockquote>
<br></div>
No. It is an error to call execute twice.<br>
<br>
The only interrogation you can do is check for 'Terminated'.<div class="im"><br></div></blockquote><div><br>Isn't it possible to have add new fields to your thread that can be interrogated?<br>e.g. another routine wants to call the thread's Execute method. Whenever the thread is executing it sets a field named FProcessing:= true, so the routing which wants to call the thread's execute method can read FProcessing and not call the execute until FProcessing is false.<br>
Is this possible?<br><br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Suspend and Resume have been deprecated, and I want to know how a thread can<br>
be suspended.<br>
</blockquote>
<br></div>
There is - to my knowledge - no safe way of doing so.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
If a thread is not set to FreeOnTerminate, can a thread suspend itself by<br>
using Terminate or some other custom function, doing some clean ups and<br>
waiting so it can be restarted by the Start procedure, by adding some custom<br>
fields to make it itself aware that it is an a paused state, so that when an<br>
Execute is sent it look up those fields, set Terminated to false and<br>
continue as though nothing has happened?<br>
</blockquote>
<br></div>
Terminate should only be used to actually terminate the thread.<br>
You can implement some custom commands to put them in a 'suspended' state,<br>
if you want. (using mutexes, semaphores and whatnot)<br>
<br></blockquote><div><br>ie this means that a routine that wants to the thread to stop can call Terminate, but it is up to the Thread itself to respond, it can't be forced?<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
You should assume only that if Execute() exits, the thread will be<br>
cleaned up.<br>
<br>
Michael.<br><font color="#888888">
<br>
--<br>
______________________________<u></u>_________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org" target="_blank">Lazarus@lists.lazarus.<u></u>freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.<u></u>freepascal.org/mailman/<u></u>listinfo/lazarus</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Frank Church<br><br>=======================<br><a href="http://devblog.brahmancreations.com">http://devblog.brahmancreations.com</a><br>