Skip to content Skip to sidebar Skip to footer

Javascript Method Processing Fixed By Alert()

I have SWT application which uses map service API (http://mapy.cz particularly) for acquiring image as background for some additional drawings based on that provided map data. Befo

Solution 1:

That alert has a visible effect here points in the direction of you having a race condition, where the blocking alert call allows the other 'thread' of execution to catch up.

So, you might want to take a look at the order of which your code executes, for instance by using console.log throughout to trace.

Solution 2:

As Sean Kinsey hinted it's really problem of browser component, that needs to be stalled until JavaScript thread finishes all necessary steps.

I've found workaround, cause in SWT GUI components have to take care about their event handling themselves, it's though possible to stall the browser until JavaScript finishes.

browser.evaluate("hideControls();");
for(int i = 0; i < 20; i++) {
    if(!display.readAndDispatch()); display.sleep();
}

It's ugly workaround, but 20 'ticks' for browser to do some trivial DOM manipulation should be enough (I hope).

Post a Comment for "Javascript Method Processing Fixed By Alert()"