[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Does browser rendering occur in the Display thread?

Here's a quick snippet that shows the problem. When I run it the console displays "after flush events" before the status text listener fires.

public class BrowserThreading {
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);

		shell.setLayout(new FillLayout());

		Browser browser = new Browser(shell, SWT.NONE);
		browser.addStatusTextListener(new StatusTextListener() {
			public void changed(StatusTextEvent event) {
				if (event.text.equals("onload")) //$NON-NLS-1$
					System.out.println("status event " + event.text); //$NON-NLS-1$
			}
		});

browser.setText("<html><body onload=\"window.status='onload';\">body content</body></html>"); //$NON-NLS-1$

		// flush all events
		while (display.readAndDispatch());

		System.out.println("after flush events"); //$NON-NLS-1$

		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}

		display.dispose();
	}
}

Brad Reynolds wrote:
I'm trying to write some tests that depend upon content being rendered in the Browser control. Does this rendering happen in the Display thread or does the browser have it's own? If the OS matters I'm running on WinXP.

Thanks,
Brad