[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] ProgressBar scroll Problem when run asynchronism thread at sametime

Hi,

I'm trying to use ProgressBar, but I met problem when I use INDETERMINATE mode and then start a asynchronism thread, see below code:

 Display display = new Display();
 final Shell shell = new Shell(display);
 shell.setBounds(100, 100, 400, 300);
		
 display.asyncExec(new Runnable(){

public void run() {
try {
Thread.sleep(5000);
//simulate long time task
} catch (InterruptedException e) {
//ignore
}
}

});
final ProgressBar progressBar = new ProgressBar(shell, SWT.INDETERMINATE);
progressBar.setMaximum(100);
progressBar.setMinimum(0);
progressBar.setSelection(20);
progressBar.setBounds(10, 15, 225, 20);

shell.open();
while(!shell.isDisposed())
{
if(!display.readAndDispatch())
display.sleep();
}


The progress bar seems be blocked, and start scroll till the asynchronism thread exit.
Using asyncExec() here as it need to update some UI elements when this thread is running.
Does some one know why the progressBar do not scroll when a asynchronism thread is running?
Is there some other solution can do same things?
What I want to do is when the back thread is running, it will update some UI element, and when it finished, it will notify UI to displose the progressBar.


Thanks.