Tuesday, March 26, 2013

The protocol of IProgressMonitor


Very nice write-up on this:
http://www.eclipse.org/articles/Article-Progress-Monitors/article.html
http://www.eclipse.org/articles/Article-Progress-Monitors/article.html#Ensure_to_always_complete_your_monitor


One contract pattern described above is that if beginTask() is ever called, done() MUST be called. This is achieved by always following this code pattern (all code is simplified):
monitor = … // somehow get a new progress monitor which is in a pristine state
// figure some things out such as number of items to process etc…
try
 {
 monitor.beginTask(…)
 // do stuff and call worked() for each item worked on, and check for cancellation
 }
finally
 {
 monitor.done()
 }

No comments:

Post a Comment