我使用TWebBrowser来显示Google地图。问题是它在加载地图时会阻塞主UI线程。是否可能在单独的线程中更新地图?
编辑: RRUZ,你是对的,TWebBrowser有用于URL的异步加载。 但是我找到了它阻塞的原因:
if WaitWhileProcessing and (MapQueryResult.Count > 0) then
Result := MapQueryResult[0] as TMapQuery;
以及这个方法:
function TMapItemCollection.WaitWhileProcessing: Boolean;
var
vMaxSleepCnt: Integer;
begin
Result := True;
vMaxSleepCnt := 0;
while Processing or Loading do
begin
inc(vMaxSleepCnt);
Application.ProcessMessages;
Sleep(100);
if vMaxSleepCnt = 100 then
begin
Result := False;
Break;
end;
end;
end;
看起来要解决这个问题需要重构代码,但这不是这个问题的范围。