即使可以识别TTask,也无法识别TThread。 (“使用接口”中的“ System.Threading”部分)

时间:2019-04-09 11:19:12

标签: multithreading delphi task

用于W10 x64的Delphi 10.2 FMX应用程序 接口部分使用System.Threading。

尝试在现有代码中设置任务以进行一些通讯。 以下是在线示例TTask.Run和TThread.Synchronize,以更新UI标签。

输入TTask时。自动完成显示正常,选择并输入...

//Code...

TTask.Run(procedure
begin
  Sleep(3000);
  j:=Random(50);
//------
//Note:when TThread. is entered the autocomplete is NOT presented and
//TThread is shown as an undeclared identifier.
//------
  TThread.Synchronize(nil,
  procedure
  begin
    Label1.Text:=j.To String;
  end);
end);

// ====== 当我创建一个新的空白应用程序并将一个按钮和标签放在窗体上时,上面的代码运行正常。

如果我删除了TThread部分,则应用程序可以正常编译。

TTask和TThread都来自同一单元。

有什么建议可以测试吗?

谢谢。

0 个答案:

没有答案