Index: trunk/src/VBox/Main/include/GuestDnDSourceImpl.h
===================================================================
--- trunk/src/VBox/Main/include/GuestDnDSourceImpl.h	(revision 63182)
+++ trunk/src/VBox/Main/include/GuestDnDSourceImpl.h	(revision 63183)
@@ -27,4 +27,5 @@
 #include "GuestDnDPrivate.h"
 
+class RecvDataTask;
 struct RECVDATACTX;
 typedef struct RECVDATACTX *PRECVDATACTX;
@@ -83,7 +84,7 @@
     static Utf8Str i_hostErrorToString(int hostRc);
 
-    /** @name Thread callbacks.
+    /** @name Thread task .
      * @{ */
-    static DECLCALLBACK(int) i_receiveDataThread(RTTHREAD Thread, void *pvUser);
+    static void i_receiveDataThreadTask(RecvDataTask *pTask);
     /** @}  */
 
Index: trunk/src/VBox/Main/include/GuestDnDTargetImpl.h
===================================================================
--- trunk/src/VBox/Main/include/GuestDnDTargetImpl.h	(revision 63182)
+++ trunk/src/VBox/Main/include/GuestDnDTargetImpl.h	(revision 63183)
@@ -27,4 +27,5 @@
 struct SENDDATACTX;
 typedef struct SENDDATACTX *PSENDDATACTX;
+class SendDataTask;
 
 class ATL_NO_VTABLE GuestDnDTarget :
@@ -71,7 +72,7 @@
     static Utf8Str i_hostErrorToString(int hostRc);
 
-    /** @name Thread callbacks.
+    /** @name Thread task workers.
      * @{ */
-    static DECLCALLBACK(int) i_sendDataThread(RTTHREAD Thread, void *pvUser);
+    static void i_sendDataThreadTask(SendDataTask *pTask);
     /** @}  */
 
Index: trunk/src/VBox/Main/include/ThreadTask.h
===================================================================
--- trunk/src/VBox/Main/include/ThreadTask.h	(revision 63182)
+++ trunk/src/VBox/Main/include/ThreadTask.h	(revision 63183)
@@ -20,22 +20,23 @@
 #include "VBox/com/string.h"
 
+/**
+ * The class ThreadVoidData is used as a base class for any data which we want to pass into a thread
+ */
 struct ThreadVoidData
 {
-/*
- * The class ThreadVoidData is used as a base class for any data which we want to pass into a thread
- */
 public:
-    ThreadVoidData(){};
-    virtual ~ThreadVoidData(){};
+    ThreadVoidData() { }
+    virtual ~ThreadVoidData() { }
 };
+
 
 class ThreadTask
 {
 public:
-    ThreadTask(const Utf8Str &t) : m_pThread(NULL), m_strTaskName(t)
-    { };
+    ThreadTask(const Utf8Str &t) : m_hThread(NIL_RTTHREAD), m_strTaskName(t)
+    { }
 
     virtual ~ThreadTask()
-    { };
+    { }
 
     HRESULT createThread(void);
@@ -44,5 +45,5 @@
 
     virtual void handler() = 0;
-    inline Utf8Str getTaskName() const {return m_strTaskName;};
+    inline Utf8Str getTaskName() const { return m_strTaskName; }
 
 protected:
@@ -50,7 +51,9 @@
     static DECLCALLBACK(int) taskHandlerThreadProc(RTTHREAD thread, void *pvUser);
 
-    ThreadTask():m_pThread(NULL), m_strTaskName("GenericTask"){};
+    ThreadTask() : m_hThread(NIL_RTTHREAD), m_strTaskName("GenericTask")
+    { }
 
-    PRTTHREAD m_pThread;
+    /** The worker thread handle (may be invalid if the thread has shut down). */
+    RTTHREAD m_hThread;
     Utf8Str m_strTaskName;
 };
Index: trunk/src/VBox/Main/src-all/ThreadTask.cpp
===================================================================
--- trunk/src/VBox/Main/src-all/ThreadTask.cpp	(revision 63182)
+++ trunk/src/VBox/Main/src-all/ThreadTask.cpp	(revision 63183)
@@ -51,5 +51,5 @@
 HRESULT ThreadTask::createThread(void)
 {
-    return createThreadInternal(RTTHREADTYPE_MAIN_WORKER, NULL /*pThread*/);
+    return createThreadInternal(RTTHREADTYPE_MAIN_WORKER, NULL /*phThread*/);
 }
 
@@ -62,5 +62,5 @@
 HRESULT ThreadTask::createThreadWithType(RTTHREADTYPE enmType)
 {
-    return createThreadInternal(enmType, NULL /*pThread*/);
+    return createThreadInternal(enmType, NULL /*phThread*/);
 }
 
@@ -72,9 +72,9 @@
  * completion and termination of the task thread!  Use with care!
  *
- * @param   pThread     Handle of the worker thread.
+ * @param   phThread    Handle of the worker thread.
  */
-HRESULT ThreadTask::createThreadWithRaceCondition(PRTTHREAD pThread)
+HRESULT ThreadTask::createThreadWithRaceCondition(PRTTHREAD phThread)
 {
-    return createThreadInternal(RTTHREADTYPE_MAIN_WORKER, pThread);
+    return createThreadInternal(RTTHREADTYPE_MAIN_WORKER, phThread);
 }
 
@@ -86,8 +86,7 @@
  * @note Always consumes @a this!
  */
-HRESULT ThreadTask::createThreadInternal(RTTHREADTYPE enmType, PRTTHREAD pThread)
+HRESULT ThreadTask::createThreadInternal(RTTHREADTYPE enmType, PRTTHREAD phThread)
 {
-    m_pThread = pThread; /** @todo this is utter non-sense! */
-    int vrc = RTThreadCreate(m_pThread,
+    int vrc = RTThreadCreate(&m_hThread,
                              taskHandlerThreadProc,
                              (void *)this,
@@ -97,5 +96,9 @@
                              this->getTaskName().c_str());
     if (RT_SUCCESS(vrc))
+    {
+        if (phThread)
+            *phThread = m_hThread;
         return S_OK;
+    }
 
     delete this;
@@ -116,8 +119,9 @@
 
     /*
-    *  handler shall catch and process all possible cases as errors and exceptions.
-    */
+     *  handler shall catch and process all possible cases as errors and exceptions.
+     */
     pTask->handler();
 
+    pTask->m_hThread = NIL_RTTHREAD; /* unnecessary, but whatever. */
     delete pTask;
     return VINF_SUCCESS;
Index: trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp	(revision 63182)
+++ trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp	(revision 63183)
@@ -86,5 +86,5 @@
     void handler()
     {
-        int vrc = GuestDnDSource::i_receiveDataThread(*m_pThread, this);
+        GuestDnDSource::i_receiveDataThreadTask(this);
     }
 
@@ -962,4 +962,8 @@
 #endif /* VBOX_WITH_DRAG_AND_DROP_GH */
 
+/**
+ * @returns VBox status code that the caller ignores. Not sure if that's
+ *          intentional or not.
+ */
 int GuestDnDSource::i_receiveData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout)
 {
@@ -1062,10 +1066,8 @@
 
 /* static */
-DECLCALLBACK(int) GuestDnDSource::i_receiveDataThread(RTTHREAD Thread, void *pvUser)
-{
-    LogFlowFunc(("pvUser=%p\n", pvUser));
-
-    RecvDataTask *pTask = (RecvDataTask *)pvUser;
-    AssertPtrReturn(pTask, VERR_INVALID_POINTER);
+DECLCALLBACK(void) GuestDnDSource::i_receiveDataThreadTask(RecvDataTask *pTask)
+{
+    LogFlowFunc(("pTask=%p\n", pTask));
+    AssertPtrReturnVoid(pTask);
 
     const ComObjPtr<GuestDnDSource> pThis(pTask->getSource());
@@ -1073,10 +1075,16 @@
 
     AutoCaller autoCaller(pThis);
-    if (FAILED(autoCaller.rc())) return VERR_COM_INVALID_OBJECT_STATE;
-
-    int rc = RTThreadUserSignal(Thread);
-    AssertRC(rc);
-
-    rc = pThis->i_receiveData(pTask->getCtx(), RT_INDEFINITE_WAIT /* msTimeout */);
+    if (FAILED(autoCaller.rc()))
+        return;
+
+    int vrc = RTThreadUserSignal(RTThreadSelf());
+    AssertRC(vrc);
+
+    vrc = pThis->i_receiveData(pTask->getCtx(), RT_INDEFINITE_WAIT /* msTimeout */);
+/** @todo
+ *
+ *  r=bird: What happens with @a vrc?
+ *
+ */
 
     AutoWriteLock alock(pThis COMMA_LOCKVAL_SRC_POS);
@@ -1085,6 +1093,5 @@
     pThis->mDataBase.m_cTransfersPending--;
 
-    LogFlowFunc(("pSource=%p returning rc=%Rrc\n", (GuestDnDSource *)pThis, rc));
-    return rc;
+    LogFlowFunc(("pSource=%p vrc=%Rrc (ignored)\n", (GuestDnDSource *)pThis, vrc));
 }
 
Index: trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp	(revision 63182)
+++ trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp	(revision 63183)
@@ -90,6 +90,5 @@
     void handler()
     {
-        int vrc = GuestDnDTarget::i_sendDataThread(*m_pThread, this);
-        NOREF(vrc);
+        GuestDnDTarget::i_sendDataThreadTask(this);
     }
 
@@ -558,10 +557,9 @@
 
 /* static */
-DECLCALLBACK(int) GuestDnDTarget::i_sendDataThread(RTTHREAD Thread, void *pvUser)
-{
-    LogFlowFunc(("pvUser=%p\n", pvUser));
-
-    SendDataTask *pTask = (SendDataTask *)pvUser;
-    AssertPtrReturn(pTask, VERR_INVALID_POINTER);
+void GuestDnDTarget::i_sendDataThreadTask(SendDataTask *pTask)
+{
+    LogFlowFunc(("pTask=%p\n", pTask));
+
+    AssertPtrReturnVoid(pTask);
 
     const ComObjPtr<GuestDnDTarget> pThis(pTask->getTarget());
@@ -569,10 +567,16 @@
 
     AutoCaller autoCaller(pThis);
-    if (FAILED(autoCaller.rc())) return VERR_COM_INVALID_OBJECT_STATE;
-
-    int rc = RTThreadUserSignal(Thread);
-    AssertRC(rc);
-
-    rc = pThis->i_sendData(pTask->getCtx(), RT_INDEFINITE_WAIT /* msTimeout */);
+    if (FAILED(autoCaller.rc()))
+        return;
+
+    int vrc = RTThreadUserSignal(RTThreadSelf());
+    AssertRC(vrc);
+
+    vrc = pThis->i_sendData(pTask->getCtx(), RT_INDEFINITE_WAIT /* msTimeout */);
+/** @todo
+ *
+ *  r=bird: What happens with @a vrc?
+ *
+ */
 
     AutoWriteLock alock(pThis COMMA_LOCKVAL_SRC_POS);
@@ -581,6 +585,5 @@
     pThis->mDataBase.m_cTransfersPending--;
 
-    LogFlowFunc(("pTarget=%p returning rc=%Rrc\n", (GuestDnDTarget *)pThis, rc));
-    return rc;
+    LogFlowFunc(("pTarget=%p vrc=%Rrc (ignored)\n", (GuestDnDTarget *)pThis, vrc));
 }
 
@@ -779,4 +782,8 @@
 }
 
+/**
+ * @returns VBox status code that the caller ignores. Not sure if that's
+ *          intentional or not.
+ */
 int GuestDnDTarget::i_sendData(PSENDDATACTX pCtx, RTMSINTERVAL msTimeout)
 {
