C # message queue and event processing (Java)

Source: Internet
Author: User

Recently, C # is used to create one thing. In this case, another event is repeatedly triggered in the Click Event of a button, and each time you have to deal with the last exciting event after the next cycle, please see the specific post: http://topic.csdn.net/u/20111214/14/5dcc7617-d294-428f-9510-d46edab305de.html, so far no one has replied...

At first, we thought it was a problem of inter-process synchronization. Therefore, we used a global variable to synchronize the two processes.ProgramIt's dead.

During multiple scheduling times, it was found that MessageBox can be used for the purpose, but the implementation is ugly and there is a pop-up window that keeps jumping.

During the data search process, you can see the application in other places. doevents () is used to give a try. It turns out that it is not a synchronization problem between two processes, but a problem of the processing sequence of two events in a process, which is described in csdn as follows:The application. doevents method processes all Windows messages in the message queue. When running Windows Forms, it creates a new form and waits for processing events. This form processes allCode. All other events are waiting in the queue. When the code processes events, the application does not respond. For example, when another window is dragged to the front of the window, the window is not re-drawn.

In the past, each process had a message queue, and each event call was put in this queue. Then, each event was processed in order, and there was no overlap between events, the doevents method tells the thread to process all messages in the queue at this call time.

 

For Java, I will certainly think of how the event processing sequence in Java is? In JVM specification, you can see:

  • awtevents which were actually enqueued to a participant eventqueue (note that events being posted to the
    eventqueue can be coalesced) are dispatched:

    • sequentially.
      That is, it is not permitted that several events from this queue are dispatched simultaneously.
    • in the same order as they are enqueued.
      That is, if awtevent A is enqueued to
      eventqueue before awtevent B then event B will not be dispatched before event.

    originally, these events were put into a queue and then executed in FIFO order. Is there anything like application. the doevents () method allows the JVM to respond to other events after the event during the execution of an event. For example, the above awtevent A has a loop, every time the loop body puts an event B in the event queue, what should I do to get the processing result of Event B before the next cycle starts?

    no answer is found currently...

    I posted a post and said that I have no technical score...

  • 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.