Update TWebBrowser in a separate thread? Update TWebBrowser in a separate thread? multithreading multithreading

Update TWebBrowser in a separate thread?


When the if statement is executed and calls WaitWhileProcessing to evaluate the condition, it loops a 100 times with a 10th of a second sleep. But what messages are waiting when calling ProcessMessages? Could the method be called again recursively? It will never get to the sleep but keeps invoking this method. By the way, be aware that ProcessMessages is really bad practice, but for now... try this:

var  isWaitWhileProcessingBusy :boolean = false;function TMapItemCollection.WaitWhileProcessing: Boolean;var vSleepCnt: Integer;begin        if not isWaitWhileProcessingBusy then  begin    isWaitWhileProcessingBusy = true;    vSleepCnt := 0;    while Processing or Loading or vSleepCnt < 100 do    begin      inc(vSleepCnt);      Application.ProcessMessages;      Sleep(100);    end;    isWaitWhileProcessingBusy := false;  end;  Result = Processing or Loading;end;

As you can see I also changed some other minor things. The break is not in the while condition and the result is simply the result of Processing or Loading (because that expression gives the actual result). The extra isWaitWhileProcessingBusy outside of the function keeps the message loop from re-entering. Hopefully that will prevent locking up the user interface. This also isn't best practice but for now it just might help to resolve and with it pinpoint the problem.

Is there a reason why you poll Loading/Processing? Wouldn't it be much easier to use the OnDocumentComplete event of TWebBrowser?

... and another thought crossed my mind... Have you checked the task manager? google maps is using flash, an activex component also using the main UI Thread. This could also be the resource hog causing starvation.

Good luck!