1、在{$mode objfpc}{$H+} 后加
{$ModeSwitch ANONYMOUSFUNCTIONS}
2、例子
如
Application.QueueAsyncCall(procedure (Data:PtrInt) var i:Integer; begin i:=1;i:=2 end,0);
linux下对UI操作最好都用这个
3、传参数
type
TLogMsgData = record
Text: string;
end;
PLogMsgData = ^TLogMsgData;
---------------------------------------------------------------------------
var
LogMsgToSend: PLogMsgData;
begin
New(LogMsgToSend);
LogMsgToSend^.Text:= AMsg;
Application.QueueAsyncCall(procedure (Data:PtrInt)
var
ReceivedLogMsg: TLogMsgData;
begin
ReceivedLogMsg := PLogMsgData(Data)^;
//处理程序
end, PtrInt(LogMsgToSend));