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