Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 343560

Summary: Display.ayncExec(null) does not cause readAndDispatch() to return true.
Product: [Eclipse Project] Platform Reporter: Silenio Quarti <Silenio_Quarti>
Component: SWTAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r
Version: 3.7   
Target Milestone: 3.7 M7   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
fix none

Description Silenio Quarti CLA 2011-04-21 10:48:58 EDT
Run this snippet and stop moving the mouse or typing. On all platforms but cocoa, you get a sequence 
like this printed to the console.

loop=true
loop=false
loop=true
loop=false


import org.eclipse.swt.widgets.*;

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

	new Thread() {
		public void run() {
			while (!display.isDisposed()) {
				//1
//				display.asyncExec(new Runnable() {
//					public void run() {
//					}
//				});
				
				//2
				display.asyncExec(null);
				
				//3
//				display.wake();
				try {
					Thread.sleep(500);
				} catch (Throwable e) {}
			}
		}
	}.start();

	shell.pack();
	shell.open();
	while (!shell.isDisposed()) {
		boolean events = display.readAndDispatch();
		System.out.println("loop=" + events);
		if (!events)
			display.sleep();
	}
	display.dispose();
}
}
Comment 1 Silenio Quarti CLA 2011-04-21 10:50:09 EDT
Created attachment 193840 [details]
fix
Comment 2 Silenio Quarti CLA 2011-04-21 10:50:50 EDT
Fixed > 20110421.