samedi 18 avril 2015

std::thread::detach hangs in VS2013

My DLL application creates a new class in an exported function when it gets called. The class constructor creates a new thread. After calling detach() the main thread does NOT continue and the entire application hangs.


In class constructor:



spawn().detach();


private member function:



std::thread spawn() {
return std::thread([=] { WriteProcess(false); });
}


WriteProcess:



for (;; std::this_thread::sleep_for(std::chrono::milliseconds(LOG_THREAD_TICK_RATE)))
{
// does stuff
}


Omitting lambdas for creating a thread does not solve it.


Using CreateThread this issue does not occur and WriteProcess works as expected.


I am using VS2013 C++11 on Windows 8 and I'm currently not able to debug the process where my dll gets loaded into.


Aucun commentaire:

Enregistrer un commentaire