+ wxMacAutoreleasePool autoreleasepool;
+
+ EventRef theEvent;
+
+ OSStatus status = ReceiveNextEvent(0, NULL, m_sleepTime, true, &theEvent) ;
+
+ switch (status)
+ {
+ case eventLoopTimedOutErr :
+ if ( wxTheApp->ProcessIdle() )
+ m_sleepTime = kEventDurationNoWait ;
+ else
+ {
+ m_sleepTime = kEventDurationSecond;
+#if wxUSE_THREADS
+ wxMutexGuiLeave();
+ wxMilliSleep(20);
+ wxMutexGuiEnter();
+#endif
+ }
+ break;
+
+ case eventLoopQuitErr :
+ // according to QA1061 this may also occur
+ // when a WakeUp Process is executed
+ break;
+
+ default:
+ if ( wxTheApp )
+ wxTheApp->MacSetCurrentEvent( theEvent, NULL );
+
+ OSStatus status = SendEventToEventTarget(theEvent, GetEventDispatcherTarget());
+ if (status == eventNotHandledErr && wxTheApp)
+ wxTheApp->MacHandleUnhandledEvent(theEvent);
+
+ ReleaseEvent( theEvent );
+ m_sleepTime = kEventDurationNoWait ;
+ break;
+ }
+