Search code examples
windowsmultithreadingwxwidgets

Are windows events handled sequentially or in parallel?


I always thought that the events in an applications event queue were handles sequentially, but because of some otherwise hardly to explain misbehaviour in an application of mine, I need to ask: Can it happen that eventhandlers for different events are runnung in parallel? I am using wxWidgets and its event handling mechanism, in case that matters; also I do use multithreading for other purpose, with a "main" and a "worker" thread (wxThreadHelper) and was under the impression that the usual events would only be handled by the - single - main thread - and that single-threadedly. Can someone confirm one way or the other?

EDIT: I am talking about what is a message in Windows parlance (WM_PAINT, WM_KEYDOWN etc.) , but I talked about events because of the wxWidgets naming convention (wxPaintEvent etc.). Sorry for the confusion. In fact it may even matter that I use wxWidgets mechanisms instead of Windows own; e.g. maybe wxWidgets pops Messages singlethreadedly and dispatches them to OnFoobarHandler() multithreadedly or vice versa - I don't know (though I thought I did ).


Solution

  • Events are only handled in the main, UI thread. Only it has an event loop and all the handlers are called from it and hence execute on the same thread.

    There is no magic.