1. Display.getcurrent () Gets the display object of the current thread, if the display object that is currently in the non-UI thread is empty, and general display.getcurrent () is used to determine whether the UI thread 2 is currently Asynchronous refresh issues,
- Asynchronous tasks need to be executed in a non-UI thread,
- It is necessary to use Display.asynexec (runnable) to perform a specific update of the UI effect when updating the UI to ensure that the thread is non-blocking
The above method is effective in RCP, which requires a mouse click once to refresh the UI in a rap.
Btnnewbutton.addselectionlistener (New Selectionadapter () {@Overridepublic void widgetselected (Selectionevent e) {New Thread (New Runnable () {@Overridepublic void run () {try {thread.sleep ()} catch (Interruptedexception e) { E.printstacktrace ();} Display.getcurrent (). Asyncexec (New Runnable () {//null point ' current thread ' is not UI Threadshell.getdisplay (). Asyncexec (New Runnable () {@Overridepublic void run () {Text.settext ("My Special is asynchronous!!!?? ");}});}}). Start ();}});
The need to implement the asynchronous UI refresh effect (data push in the Web) needs to be implemented using the following model (although this model is not good for blocking interactions)
Container.getdisplay (). Timerexec (0, New Runnable () { @Override public void Run () { display.timeexec (1000 , this); } );
Eclipse Rap develops asynchronous refresh UI processing