Index: /trunk/src/VBox/Main/include/VFSExplorerImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/VFSExplorerImpl.h	(revision 60447)
+++ /trunk/src/VBox/Main/include/VFSExplorerImpl.h	(revision 60448)
@@ -70,5 +70,5 @@
     //////////////////////////////////////////////////////////////////////////////////
     //
-    struct TaskVFSExplorer;  /* Worker thread helper */
+    class TaskVFSExplorer;  /* Worker thread helper */
     struct Data;
     Data *m;
Index: /trunk/src/VBox/Main/src-server/VFSExplorerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/VFSExplorerImpl.cpp	(revision 60447)
+++ /trunk/src/VBox/Main/src-server/VFSExplorerImpl.cpp	(revision 60448)
@@ -33,4 +33,5 @@
 #include "AutoCaller.h"
 #include "Logging.h"
+#include "ThreadTask.h"
 
 #include <memory>
@@ -149,6 +150,7 @@
 }
 
-struct VFSExplorer::TaskVFSExplorer
-{
+class VFSExplorer::TaskVFSExplorer : public ThreadTask
+{
+public:
     enum TaskType
     {
@@ -162,8 +164,15 @@
           progress(aProgress),
           rc(S_OK)
-    {}
+    {
+        m_strTaskName = "Explorer::Task";
+    }
     ~TaskVFSExplorer() {}
 
-    int startThread();
+private:
+    void handler()
+    {
+        int vrc = taskThread(NULL, this);
+    }
+
     static DECLCALLBACK(int) taskThread(RTTHREAD aThread, void *pvUser);
     static DECLCALLBACK(int) uploadProgress(unsigned uPercent, void *pvUser);
@@ -171,4 +180,5 @@
     TaskType taskType;
     VFSExplorer *pVFSExplorer;
+
     ComObjPtr<Progress> progress;
     HRESULT rc;
@@ -176,25 +186,15 @@
     /* task data */
     std::list<Utf8Str> filenames;
+
+    friend class VFSExplorer;
 };
-
-int VFSExplorer::TaskVFSExplorer::startThread()
-{
-    int vrc = RTThreadCreate(NULL, VFSExplorer::TaskVFSExplorer::taskThread, this,
-                             0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
-                             "Explorer::Task");
-
-    if (RT_FAILURE(vrc))
-        return VFSExplorer::setErrorStatic(E_FAIL, Utf8StrFmt("Could not create taskThreadVFS (%Rrc)\n", vrc));
-
-    return vrc;
-}
 
 /* static */
 DECLCALLBACK(int) VFSExplorer::TaskVFSExplorer::taskThread(RTTHREAD /* aThread */, void *pvUser)
 {
-    std::auto_ptr<TaskVFSExplorer> task(static_cast<TaskVFSExplorer*>(pvUser));
-    AssertReturn(task.get(), VERR_GENERAL_FAILURE);
-
-    VFSExplorer *pVFSExplorer = task->pVFSExplorer;
+    TaskVFSExplorer* pTask = static_cast<TaskVFSExplorer*>(pvUser);
+    AssertReturn(pTask, VERR_GENERAL_FAILURE);
+
+    VFSExplorer *pVFSExplorer = pTask->pVFSExplorer;
 
     LogFlowFuncEnter();
@@ -203,10 +203,10 @@
     HRESULT rc = S_OK;
 
-    switch(task->taskType)
+    switch(pTask->taskType)
     {
         case TaskVFSExplorer::Update:
         {
             if (pVFSExplorer->m->storageType == VFSType_File)
-                rc = pVFSExplorer->i_updateFS(task.get());
+                rc = pVFSExplorer->i_updateFS(pTask);
             else if (pVFSExplorer->m->storageType == VFSType_S3)
                 rc = VERR_NOT_IMPLEMENTED;
@@ -216,5 +216,5 @@
         {
             if (pVFSExplorer->m->storageType == VFSType_File)
-                rc = pVFSExplorer->i_deleteFS(task.get());
+                rc = pVFSExplorer->i_deleteFS(pTask);
             else if (pVFSExplorer->m->storageType == VFSType_S3)
                 rc = VERR_NOT_IMPLEMENTED;
@@ -222,5 +222,5 @@
         }
         default:
-            AssertMsgFailed(("Invalid task type %u specified!\n", task->taskType));
+            AssertMsgFailed(("Invalid task type %u specified!\n", pTask->taskType));
             break;
     }
@@ -409,11 +409,8 @@
 
         /* Initialize our worker task */
-        std::auto_ptr<TaskVFSExplorer> task(new TaskVFSExplorer(TaskVFSExplorer::Update, this, progress));
-
-        rc = task->startThread();
-        if (FAILED(rc)) throw rc;
-
-        /* Don't destruct on success */
-        task.release();
+        TaskVFSExplorer* pTask = new TaskVFSExplorer(TaskVFSExplorer::Update, this, progress);
+
+        //this function delete task in case of exceptions, so there is no need in the call of delete operator
+        rc = pTask->createThread(NULL, RTTHREADTYPE_MAIN_HEAVY_WORKER);
     }
     catch (HRESULT aRC)
@@ -526,15 +523,12 @@
 
         /* Initialize our worker task */
-        std::auto_ptr<TaskVFSExplorer> task(new TaskVFSExplorer(TaskVFSExplorer::Delete, this, progress));
+        TaskVFSExplorer* pTask = new TaskVFSExplorer(TaskVFSExplorer::Delete, this, progress);
 
         /* Add all filenames to delete as task data */
         for (size_t i = 0; i < aNames.size(); ++i)
-            task->filenames.push_back(aNames[i]);
-
-        rc = task->startThread();
-        if (FAILED(rc)) throw rc;
-
-        /* Don't destruct on success */
-        task.release();
+            pTask->filenames.push_back(aNames[i]);
+
+        //this function delete task in case of exceptions, so there is no need in the call of delete operator
+        rc = pTask->createThread(NULL, RTTHREADTYPE_MAIN_HEAVY_WORKER);
     }
     catch (HRESULT aRC)
