Suppose I have an API method which is intended to perform long-term operation and which therefore receives monitor as a parameter, like in
org.eclipse.ui.part.EditorPart.doSave(IProgressMonitor monitor)
If I had single operation to do in this method, I would code, for instance, to write an image
imageFile.create(imageInput, false, monitor);
But what if I do SEVERAL long-term sub-routines inside single doSave
? How to make that monitor measures each with 50% or something?
imageFile.create(imageInput, false, monitor);
descriptionFile.create(descriptionInput, false, monitor);
Use SubProgressMonitor
for each call the methods:
monitor.beginText("task", 100);
imageFile.create(imageInput, false, new SubProgressMonitor(monitor, 50));
descriptionFile.create(descriptionInput, false, new SubProgressMonitor(monitor, 50));
The sum of the 'tick' count given to all the sub progress monitors should match the 'tick' count given on the beginTask
call.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.