TThread.CreateAnonymousThread lazarus / 21-General ---------------------------------------------------------------------- Pe3s · 2024-11-28 20:48 Hello, for using TThread.CreateAnonymousThread thread Is there any configuration required. How can I improve the code ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);begin  TThread.CreateAnonymousThread(  procedure  begin     // code  end  ).Start;end;         Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit1.pas(325,3) Error: Illegal expressionunit1.pas(326,3) Error: Syntax error, ")" expected but "BEGIN" found ---------------------------------------------------------------------- korba812 · 2024-11-28 22:26 Probably anonymous functions should be enabled by modeswitch. Try putting {$modeswitch ANONYMOUSFUNCTIONS} in your unit. ---------------------------------------------------------------------- vercetti · 2024-11-29 08:12 Quote{$modeswitch ANONYMOUSFUNCTIONS} From which version did this become available ? I use: Lazarus 3.4 and FPC 3.2.2 and get a warning: QuoteWarning: Illegal compiler switch "ANONYMOUSFUNCTIONS+" ---------------------------------------------------------------------- Thaddy · 2024-11-29 08:31 It is only in trunk/main. Better than createanonymousthread is simply executeinthread. I gave an example some weeks ago: https://forum.lazarus.freepascal.org/index.php/topic,68823.msg532746.h tml#msg532746 And can be simplified further. In 3.2.x this is only possible by taking a function pointer instead.