message-loop

How to override wxApp::MainLoop properly (wxWidgets)?

I'm writing a cross-platform application. Is there a way in wxWidgets to define my own event loop? How to do that? I want it look like an ordinary windows PeekMessage DispachMessage loop: for(;;) { while(PeekMessage(...)) // dispatching all pending messages { // traslating, dispatching messages // also do something wit...

Run Message Loop while waiting for WaitHandle

Is there any way to process all Windows messages while the UI thread is waiting on a WaitHandle or other threading primitive? I realize that it could create very messy reentrancy problems; I want to do it anyway. EDIT: The wait occurs in the middle of a complicated function that must run on the UI thread. Therefore, moving the wait to...

WTL 8.0 _Module and Message Loop

I'm working on a WTL project, actually WTL 8.1 with VS2008. In many tutorials I've seen the usage of _Module global variable, e.g: _Module.AddMessageLoop. My current application creates a CMessageLoop in the stack at WinMain and later calls the CMessageLoop::Run () method. So far, it's running well. Anyone the reason (if it's necessary) ...

AutoResetEvent and COM Objects

I've noticed that AutoResetEvent completely freezes the message loop (sometimes) when in the middle of a WaitOne() call, effectively even blocking the signal message. IE: (UI) New thread spawned (UI) Code calls WaitOne(); timeout: 10s (T2) Thread opens device, calls Set() (UI) WaitOne blocks message loop (UI) WaitOne timeout elapsed, ...

Window moving and resizing interferes with MsgWaitForMultipleObjects

I have an application that message-loops using MsgWaitForMultipleObjects to catch additional events while pumping ui messages. It seems that as soon as a window is being moved or resized, DefWindowProc begins it's own message loop until the mouse is being released. This situation prevents from the outer loop to catch the additional messa...

Fireing Android Dialogs from another thread without Message Loop

In a SurfaceView, I'm dispatching new thread that draws on canvas within standard "LockCanvas-Draw-unlockCanvasAndPost" loop. (note that thread doesn't contains message loop). How to show Android standard Dialog from that thread? As thread doesn't have msg loop, following code doesn't work: Builder builder = new AlertDialog.Builder(th...

Threading 101: What is a Dispatcher?

Once upon a time, I remembered this stuff by heart. Over time, my understanding has diluted and I mean to refresh it. As I recall, any so called single threaded application has two threads: a) the primary thread that has a pointer to the main or DllMain entry points; and b) For applications that have some UI, a UI thread, a.k.a the se...

Erlang message loops

How does message loops in erlang work, are they sync when it comes to processing messages? As far as I understand, the loop will start by "receive"ing a message and then perform something and hit another iteration of the loop. So that has to be sync? right? If multiple clients send messages to the same message loop, then all those mes...

Code hot swapping in Erlang

I recently saw a video about Erlang on InfoQ, In that video one of the creators presented how to replace the behavior of a message loop. He was simply sending a message containing a lambda of the new version of the message loop code, which then was invoked instead of calling the old loop again. Is that code hot swapping in Erlang reffe...