multithreading - IProgressMonitor example needed for uncertain long process database transaction -


i new rcp , building 1 product have "import" feature imports approx 50000 data excel. want show progress in progress bar. have tried many examples couldn't extract required code may don't know how write proper way. please provide me example few steps can understand flow. if steps write iprogressmonitor , database connectivity code import data excel , insert database.

i need more stuff calling each method string should changed different strings have mentioned in image. doing user can aware happening behind scene.

below sample code have tried

new progressmonitordialog(shell).run(true, true, new irunnablewithprogress() { @override public void run(iprogressmonitor monitor) throws invocationtargetexception, interruptedexception { try { monitor.begintask("importing data...", iprogressmonitor.unknown);

                    if (monitor.iscanceled())                         return;                     try {                         display.getdefault().asyncexec(new runnable() {@                             override                             public void run() {                                 snippet s = new snippet();                                 // should write here ?                             }                         });                         monitor.subtask(string.valueof(i)); // how show elapse time ?                         thread.sleep(100); // when sleep thread without knowing how time take ?                      } catch (interruptedexception e) {                         e.printstacktrace();                     }                 } {                     monitor.done();                 }             }); 

thank in advance.

please click here see how expect progress bar

here basic job uses progress monitor unknown total work , informs sub task executed

job job = new job( "import data" ) {   @override   protected istatus run( iprogressmonitor monitor ) {     monitor.begintask( "importing data...", iprogressmonitor.unknown );     try {       monitor.subtask( "opening database..." );       // connect db       monitor.subtask( "reading elements..." );       // read elements       ...     } {       monitor.done();     }     return status.ok_status;   } }; job.schedule(); 

for refinements , more details should read respective articles , documentation.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -