Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp	(revision 61942)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp	(revision 61943)
@@ -924,4 +924,5 @@
 )
 {
+    /* TODO: AM need to check that the thread retrieves these events */
     switch(uMsg)
     {
@@ -942,10 +943,4 @@
             break;
         }
-        case WM_CLOSE:
-            LogFunc(("got WM_CLOSE for hwnd(0x%x)", hwnd));
-            return 0;
-        case WM_DESTROY:
-            LogFunc(("got WM_DESTROY for hwnd(0x%x)", hwnd));
-            return 0;
         case WM_NCHITTEST:
             LogFunc(("got WM_NCHITTEST for hwnd(0x%x)\n", hwnd));
@@ -1051,4 +1046,5 @@
     HRESULT hr = S_FALSE;
 
+    /* Create the thread message queue*/
     PeekMessage(&Msg,
             NULL /* HWND hWnd */,
@@ -1056,4 +1052,17 @@
             WM_USER /* UINT wMsgFilterMax */,
             PM_NOREMOVE);
+    
+    /* 
+    * Send signal that message queue is ready.
+    * From this moment only the thread is ready to receive messages.
+    */
+    BOOL bRc = SetEvent(pMon->hEvent);
+    if (!bRc)
+    {
+        DWORD winErr = GetLastError();
+        WARN_FUNC(("SetEvent failed, winErr = (%d)", winErr));
+        HRESULT tmpHr = HRESULT_FROM_WIN32(winErr);
+        Assert(tmpHr != S_OK);
+    }
 
     do
@@ -1065,13 +1074,5 @@
             );
 
-        if(!bResult) /* WM_QUIT was posted */
-        {
-            hr = S_FALSE;
-            Log(("VBoxTray: GetMessage returned FALSE\n"));
-            VBoxRrRetryStop();
-            break;
-        }
-
-        if(bResult == -1) /* error occurred */
+        if (bResult == -1) /* error occurred */
         {
             DWORD winEr = GetLastError();
@@ -1087,4 +1088,12 @@
         }
 
+        if(!bResult) /* WM_QUIT was posted */
+        {
+            hr = S_FALSE;
+            Log(("VBoxTray: GetMessage returned FALSE\n"));
+            VBoxRrRetryStop();
+            break;
+        }
+        
         switch (Msg.message)
         {
@@ -1108,15 +1117,4 @@
 static DWORD WINAPI vboxRrRunnerThread(void *pvUser)
 {
-    PVBOXRR pMon = &g_VBoxRr;
-
-    BOOL bRc = SetEvent(pMon->hEvent);
-    if (!bRc)
-    {
-        DWORD winErr = GetLastError();
-        WARN_FUNC(("SetEvent failed, winErr = (%d)", winErr));
-        HRESULT tmpHr = HRESULT_FROM_WIN32(winErr);
-        Assert(tmpHr != S_OK);
-    }
-
     HRESULT hr = vboxRrWndInit();
     Assert(hr == S_OK);
