eclipse - MessageDialog title is coming 'Not Responding' -
i performing long running operation , showing message dialog "fetching details" , closing same once operation performed.
try{ messagedialog dialog = new messagedialog(display.getdefault().getactiveshell(), "information", null, "fetching details...", messagedialog.none , new string[] {}, -1); dialog.setblockonopen(false); dialog.open(); //schedule long running operations } finally{ dialog.close() }
if operation takes more time, dialog showing not responding (title changes "information (not responding)").
how can avoid not responding status ?
you must not run long operations in ui thread. doing block thread until finish , ui become unresponsive.
run operations in background thread, or eclipse job or java 8 completeablefuture.
use display
asyncexec
in background code update ui required.
another alternative use progressmonitordialog
:
progressmonitordialog dialog = new progressmonitordialog(shell); try { dialog.run(true, true, new irunnablewithprogress() { @override public void run(iprogressmonitor monitor) { monitor.begintask("task name", iprogressmonitor.unknown); try { // todo long running code // todo check monitor.iscanceled() possible } { monitor.done(); } } }); } ... catch exceptions
Comments
Post a Comment