TIdHTTPServer的FireMonkey Android问题

时间:2019-01-15 17:47:11

标签: delphi indy

我有一个带有TTabControlTWebBrowserTIdHTTPServer的FireMonkey Android应用。

我尝试使用以下代码在TIdHTTPServer.OnCommandGet事件中将HTTP客户端重定向到新的URL:

TabControl1.ActiveTab := TabItem2;
AResponseInfo.ResponseNo := 302;
AResponseInfo.Location := ARequestInfo.Params.Values['url'];

但是我得到一个错误:

  

不是主线程的线程$ c6f02970调用Checksynchronize。

在请求到TIdHTTPServer组件之后,如何更改选项卡?

1 个答案:

答案 0 :(得分:3)

The OnCommandGet event is executed in the context of a worker thread. You are only allowed to access the user interface from the main UI thread. Move access to UI controls embedded into a call to TThread.Synchronize or TThread.Queue.

TThread.Synchronize(nil,
  procedure
  begin
    Tabcontrol1.ActiveTab:=tabitem2;
  end);
AResponseInfo.ResponseNo := 302;
AResponseInfo.Location := ARequestInfo.Params.Values['url'];