std :: thread :: detach在VS2013中挂起

时间:2015-04-18 21:56:15

标签: windows multithreading c++11

我的DLL应用程序在调用时在导出的函数中创建一个新类。类构造函数创建一个新线程。在调用detach()之后,主线程不会继续,整个应用程序都会挂起。

在类构造函数中:

spawn().detach();

私人会员功能:

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

WriteProcess:

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

省略用于创建线程的lambda不能解决它。

使用CreateThread此问题不会发生,WriteProcess按预期工作。

我在Windows 8上使用VS2013 C ++ 11,而我目前无法调试加载我的dll的过程。

0 个答案:

没有答案
相关问题