Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » UI not blocked during a long event.
UI not blocked during a long event. [message #1047195] Mon, 22 April 2013 22:52 Go to next message
Jesus   Luna Quiroga is currently offline Jesus Luna QuirogaFriend
Messages: 67
Registered: July 2009
Location: Mexico
Member

Hi,
I'm having troubles because one of the events of my application takes to long to process and I've notice the user can still do changes in the UI while this is processing.

I create a little example to simulate this situation, in this example I just put a button with a selection event and 2 text controls, and at the button's selection event I put a code that takes 10 seconds to finish and then set a string to a text control.
So if the button is clicked or selected and the 10 seconds hasn't passed yet, the user still can do changes in the controls.

 protected void createContents(Composite parent) {
        parent.setLayout(new FillLayout);
        Button button = new Button(parent, SWT.PUSH);
        button.setText("Button");        
        Text txt = new Text(parent, SWT.BORDER);        
        final Text txt2 = new Text(parent, SWT.BORDER);
        button.addSelectionListener(new SelectionListener() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			Long initial = Calendar.getInstance().getTimeInMillis();				while((initial+10000)>Calendar.getInstance().getTimeInMillis());
				txt2.setText("Button click!!");				
			}
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {}
        	
        });


I was expecting that the UI should be blocked until the 10 seconds have passed and the string was set to the text control, I mean the user can not do any change in the UI until the event finishes.

My question would be is this the behavior of RAP?

If it is, can I do something to change it, in order to block the UI while the event hasn't finished?

I hope you can help me with this.
Re: UI not blocked during a long event. [message #1047427 is a reply to message #1047195] Tue, 23 April 2013 07:31 Go to previous message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

THOU SHALT NOT execute long running tasks in the UI thread. Instead, you
must run them asynchronously in a background thread and update the UI
using Display.asyncExec() when finished. That's one of the basic rules
of UI programming with SWT.

Apart from that, in RAP 2.1, the UI is blocked when a request takes too
long.

Regards, Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:view toolbar display problem on business theme
Next Topic:WebBrowser control in C# can not display RAP applications due to error
Goto Forum:
  


Current Time: Wed Apr 24 22:49:30 GMT 2024

Powered by FUDForum. Page generated in 0.03203 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top