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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -