Forum > General

TThread.CreateAnonymousThread

(1/1)

Pe3s:
Hello, for using TThread.CreateAnonymousThread thread
Is there any configuration required.
How can I improve the code ?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin  TThread.CreateAnonymousThread(  procedure  begin     // code  end  ).Start;end;          

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit1.pas(325,3) Error: Illegal expressionunit1.pas(326,3) Error: Syntax error, ")" expected but "BEGIN" found 

korba812:
Probably anonymous functions should be enabled by modeswitch. Try putting {$modeswitch ANONYMOUSFUNCTIONS} in your unit.

vercetti:

--- Quote ---{$modeswitch ANONYMOUSFUNCTIONS}
--- End quote ---

From which version did this become available ?

I use: Lazarus 3.4 and FPC 3.2.2 and get a warning:


--- Quote ---Warning: Illegal compiler switch "ANONYMOUSFUNCTIONS+"
--- End quote ---

Thaddy:
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.html#msg532746

And can be simplified further.
In 3.2.x this is only possible by taking a function pointer instead.

Navigation

[0] Message Index

Go to full version