In my SWT Application i wish to use a progress bar <strong>(org.eclipse.swt.widgets.ProgressBar)</strong> i found examples but could not understand the proper flow and usage i need to perform background task for which, i was paused at the algorithm phase like i can analyze that there should be two threads one for background job, another for a progressbar both should execute simultaneously, i could not figure out the Implementation of this,i found plenty of examples but,i was puzzled where should i place my background task code <em>(still searching)</em>. Can anyone provide sample example that suits me.Answer1:
Did you see <a href="http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet56.java" rel="nofollow">update a progress bar (from another thread)</a> from <a href="http://www.eclipse.org/swt/snippets/#progressbar" rel="nofollow">SWT ProgressBar snippets</a> page? It explains a lot.
ProgressBar have to be asynchronous to work correctly in every GUI framework. It's job is to show some value independently on main (GUI) thread. So you have to write your own thread, which will maintain the ProgressBar, resolving current value of it and show the changes of value (rendering progress by widget itself).
In Swing, you don't have to create you own thread for ProgressBar, because the class already implements upper proposed behavior (makes itself another thread and manage the work for you). But because SWT is platform dependent (and for other reasons), you have to manage this by yourself.