Skip to content

Progress Monitor

Carsten Hammer edited this page Feb 19, 2023 · 3 revisions

since Neon (4.6)

Before

     void someMethod(IProgressMonitor pm) {
        pm.beginTask("Main Task", 100);
        SubProgressMonitor subMonitor1= new SubProgressMonitor(pm, 60);
        try {
           doSomeWork(subMonitor1);
        } finally {
           subMonitor1.done();
        }
        SubProgressMonitor subMonitor2= new SubProgressMonitor(pm, 40);
        try {
           doSomeMoreWork(subMonitor2);
        } finally {
           subMonitor2.done();
        }
     }

After

     void someMethod(IProgressMonitor pm) {
        SubMonitor subMonitor = SubMonitor.convert(pm, "Main Task", 100);
        doSomeWork(subMonitor.split(60));
        doSomeMoreWork(subMonitor.split(40));
     }

Sourcecode for this cleanup can be found at JFacePlugin.java