Index: /trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp
===================================================================
--- /trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp	(revision 22723)
+++ /trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp	(revision 22724)
@@ -493,8 +493,16 @@
 
 #ifdef VBOX
-# include <iprt/cdefs.h>
+#define USE_EVENTQUEUE  1
+
+# ifdef USE_EVENTQUEUE
+#  include <VBox/com/EventQueue.h>
+#  include <iprt/err.h>
+# else
+#  include <iprt/cdefs.h>
+# endif
 
 static nsIEventQueue* g_mainEventQ = nsnull;
 
+# ifndef USE_EVENTQUEUE /** @todo Make USE_EVENTQUEUE default. */
 // Wrapper that checks if the queue has pending events.
 DECLINLINE(bool)
@@ -616,4 +624,5 @@
 
 # endif /* RT_OS_DARWIN */
+# endif /* !USE_EVENTQUEUE */
 
 static PyObject*
@@ -623,14 +632,24 @@
 
   if (!PyArg_ParseTuple(args, "i", &aTimeout))
-    return NULL;
+    return NULL; /** @todo throw exception */
 
   nsIEventQueue* q = g_mainEventQ;
   if (q == nsnull)
-    return NULL;
-
+    return NULL; /** @todo throw exception */
+
+# ifdef USE_EVENTQUEUE
+  int rc = com::EventQueue::processThreadEventQueue(aTimeout < 0 ? RT_INDEFINITE_WAIT : (uint32_t)aTimeout);
+  if (RT_SUCCESS(rc))
+      return PyInt_FromLong(0);
+  if (   rc == VERR_TIMEOUT
+      || rc == VERR_INTERRUPTED)
+      return PyInt_FromLong(1);
+  return NULL; /** @todo throw exception */
+
+# else  /* !USE_EVENTQUEUE */
   NS_WARN_IF_FALSE(isEventQueueNative(q), "The event queue must be native!");
 
   PRInt32 result = 0;
-# ifdef RT_OS_DARWIN
+#  ifdef RT_OS_DARWIN
   if (aTimeout != 0 && !hasEventQueuePendingEvents(q))
     result = waitForEventsOnDarwin(q, aTimeout);
@@ -638,5 +657,5 @@
     q->ProcessPendingEvents();
 
-# else  /* !RT_OS_DARWIN */
+#  else  /* !RT_OS_DARWIN */
 
   PRBool hasEvents = PR_FALSE;
@@ -693,7 +712,7 @@
  ok:
   q->ProcessPendingEvents();
-# endif /* !RT_OS_DARWIN */
-
+#  endif /* !RT_OS_DARWIN */
   return PyInt_FromLong(result);
+# endif /* !USE_EVENTQUEUE */
 }
 
