It seems that my application loop is paused at these moments and I can't receive any events.
...
I attach a simple test app. Another thread sends events calling postEvent_atStart every 1000 ms and the main thread writes numbers on the window title.
...
The question is: how to process events in these situation?
That's the because the event queue in Cocoa is not exactly identical to Windows event loop.
Cocoa events processing has an extra layer of complexity. There are loop "run modes": Normal, Modal (for dialogs), Tracking (for mouse down). Certain events might not be processed in a certain mode. I.e. timer and mouse events will be processed at all times, while over events might be postponed.
Just posting an event doesn't guarantee it will be executed immediately, Cocoa might wait while the current mode is finished and only then execute the event.
If the purpose is only to synchronize threads, I'd suggest to try using
performOnMainThread method. It has a slightly less overhead than creating an Event. It also gives an option to control during what modes the selector can be performed.
This is what LCL does.
Explained hereIt should also prevent you from the need of overriding NSApplication class to get the event executed properly.