Sal*_*dor 8 delphi multithreading delphi-xe
似乎哪个Synchronize不能从使用CreateAnonymousThread创建的线程中使用,所以问题是:How i can update a VCL component from inside of a Thread created using CreateAnonymousThread?
TThread.CreateAnonymousThread(procedure
begin
//do something
UpdateCompnent();//how I can update a VCL component from here?
end
).Start;
Run Code Online (Sandbox Code Playgroud)
在这种情况下,您可以使用同步,例如:
TThread.Synchronize(nil, procedure begin UpdateComponent(); end);
Run Code Online (Sandbox Code Playgroud)
如果你想在主线程中执行异步方法调用,你可以使用TThread.Queue,例如:
TThread.Queue(nil, procedure begin UpdateComponent(); end);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3429 次 |
| 最近记录: |