Question

If multiple events are posted using wxPostEvent/wxCallAfter from same thread e.g. on button click are they supposed to be processed in same order?

In the below example wx.Callafter is used to post events, which eventually will call the callback functions, will they be called in same order, in which they were passed to wx.CallAfter

def onbutton(self, event):
    wx.CallAfter(func1)
    # some more code
    wx.CallAfter(func2)
Was it helpful?

Solution

CallAfter posts the events to the event queue and these should be processed in order. Still, they are processed on idle events, not based on function completion, so the func2 to could be processed before func1 is done depending on the timing of idle events (e.g. wx.Yield, etc.) There's a discussion about an issue with this here, and it seems that it can be sort-of tricky.

OTHER TIPS

I believe it should be guaranteed. I have some code that grabs data from the serial port in a thread and fires off events for wx to handle. Even when receiving data at 115kbps--where it would undoubtedly fire off several events before they are processed--the data shows up in order when wx calls my handler to print/log out the data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top