开发者

ProgressBar using Threads in SWT

开发者 https://www.devze.com 2023-04-02 09:28 出处:网络
In my SWT Application i wish to use a progress bar (org.eclipse.swt.widgets.ProgressBar) i found examples but could not understand the proper flow and usage i need to perform background task for whic

In my SWT Application i wish to use a progress bar (org.eclipse.swt.widgets.ProgressBar) 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 开发者_如何学Pythontask code (still searching). Can anyone provide sample example that suits me.


Did you see update a progress bar (from another thread) from SWT ProgressBar snippets 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号