Index: /trunk/src/VBox/Main/include/ThreadTask.h
===================================================================
--- /trunk/src/VBox/Main/include/ThreadTask.h	(revision 58009)
+++ /trunk/src/VBox/Main/include/ThreadTask.h	(revision 58009)
@@ -0,0 +1,40 @@
+/** @file
+ * VirtualBox ThreadTask class definition
+ */
+
+/*
+ * Copyright (C) 2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef ____H_THREADTASK
+#define ____H_THREADTASK
+
+#include "VBox/com/string.h"
+
+class ThreadTask
+{
+public:
+    ThreadTask(const Utf8Str &t) : m_strTaskName(t){};
+    virtual ~ThreadTask(){};
+    HRESULT createThread();
+    virtual void handler() = 0;
+    static DECLCALLBACK(int) taskHandler(RTTHREAD thread, void *pvUser);
+    static HRESULT i_setErrorStatic(HRESULT aResultCode, const Utf8Str &aText);
+
+    inline Utf8Str getTaskName() const {return m_strTaskName;};
+
+protected:
+    ThreadTask():m_strTaskName("GenericTask"){};
+    Utf8Str m_strTaskName;
+};
+
+#endif
+
Index: /trunk/src/VBox/Main/src-all/ThreadTask.cpp
===================================================================
--- /trunk/src/VBox/Main/src-all/ThreadTask.cpp	(revision 58009)
+++ /trunk/src/VBox/Main/src-all/ThreadTask.cpp	(revision 58009)
@@ -0,0 +1,96 @@
+/** @file
+ * Implementation of ThreadTask
+ */
+
+/*
+ * Copyright (C) 2015 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include <iprt/thread.h>
+
+#include "VirtualBoxBase.h"
+#include "ThreadTask.h"
+
+HRESULT ThreadTask::createThread()
+{
+    HRESULT rc = S_OK;
+    try
+    {
+        int vrc = RTThreadCreate(NULL,
+                                 taskHandler,
+                                 (void *)this,
+                                 0,
+                                 RTTHREADTYPE_MAIN_WORKER,
+                                 0,
+                                 this->getTaskName().c_str());
+        if (RT_FAILURE(vrc))
+        {
+            throw E_FAIL;
+        }
+    }
+    catch(HRESULT eRC)
+    {
+        rc = eRC;
+        delete this;
+    }
+    catch(std::exception& e)
+    {
+        rc = E_FAIL;
+        delete this;
+    }
+    catch(...)
+    {
+        rc = E_FAIL;
+        delete this;
+    }
+
+    return rc;
+}
+
+/**
+ * Static method that can get passed to RTThreadCreate to have a 
+ * thread started for a Task.
+ */
+/* static */ DECLCALLBACK(int) ThreadTask::taskHandler(RTTHREAD /* thread */, void *pvUser)
+{
+    HRESULT rc = S_OK;
+    if(pvUser == NULL)
+        return VERR_INVALID_POINTER;
+
+    ThreadTask *pTask = static_cast<ThreadTask *>(pvUser);
+    try
+    {
+        pTask->handler();
+    }
+    catch(HRESULT eRC)
+    {
+        rc = E_FAIL;
+    }
+    catch(std::exception& e)
+    {
+        rc = E_FAIL;
+    }
+    catch(...)
+    {
+        rc = E_FAIL;
+    }
+
+    delete pTask;
+
+    return 0;
+}
+
+/*static*/ HRESULT ThreadTask::i_setErrorStatic(HRESULT aResultCode,
+                                    const Utf8Str &aText)
+{
+    return aResultCode;
+}
+
