<p>Am 01.02.2016 13:54 schrieb "Michael Van Canneyt" <<a href="mailto:michael@freepascal.org">michael@freepascal.org</a>>:<br>
><br>
><br>
><br>
> On Mon, 1 Feb 2016, Anthony Walter wrote:<br>
><br>
>> Just a bit of information, my Cross.Codebot library has threading built in<br>
>> to the socket protocol implementations, so with regards to explaining it I<br>
>> could just show the source code or I could write it a again just to<br>
>> demonstrate.<br>
>><br>
>> With regards to complexity, I never define a new thread class, which is the<br>
>> typical way most people think about working with threads in Free Pascal.<br>
>> Instead I have one thread class defined in my System unit, and you pass it<br>
>> your execute method along with an optional status handler. Your execute is<br>
>> called, the thread object is freed for you automatically, and you don't<br>
>> need to declare a new type.<br>
>><br>
><br>
> [snip]<br>
><br>
><br>
>> procedure TDownloadForm.DownloadClick(Sender: TObject);<br>
>> begin<br>
>> if FThread <> nil then<br>
>> Exit;<br>
>> FThread := TSimpleThread.Create(Download, DownloadStatus,<br>
>> DownloadComplete);<br>
>> end;<br>
><br>
><br>
> This mechanism could easily be added as class static methods to TThread<br>
> itself. It would make life easier for many simple cases.<br>
><br>
> Class Procedure TThread.Spawn(MyProcedure,OnStatus,OnTerminate : TThreadProcedure); static;<br>
><br>
> Or "ExecuteInThread" instead of "Spawn".<br>
><br>
> Would you care to enter this as a feature request ?</p>
<p>Current Delphis have something similar for anonymous functions already, so we should use the same name, but with "of object" procvars instead (note: the resulting thread class will be TAnonymousThread).</p>
<p>Regards,<br>
Sven</p>