Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343560 - Display.ayncExec(null) does not cause readAndDispatch() to return true.
Summary: Display.ayncExec(null) does not cause readAndDispatch() to return true.
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 3.7 M7   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-21 10:48 EDT by Silenio Quarti CLA
Modified: 2011-04-21 12:00 EDT (History)
1 user (show)

See Also:


Attachments
fix (1.00 KB, patch)
2011-04-21 10:50 EDT, Silenio Quarti CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.