Eclipse Rap develops asynchronous refresh UI processing

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.