Am in the process of migrating my project to the c++11 standard with msvc110, unfortunately a thread variable, used on a dll, is behaving different from what the boost version I had.
So, originally this was working on msvc90, basically the Dll calls an InitDll where a thread was created. The thread basically served as a listener along with the main thread of the dll. Now when I create the thread it hangs and does nothing, not even executing the function which was used to initialize the thread.
Could you help me explaining how can I get same behavior as for the boost version?
EDIT: THE CODE
Sorry, couldn't reply the code on the comments
An application uses a logger through a dll. To use the logger in a very simple console application goes like this
#include <Somewhere/Logger.h>
int main()
{
COOL_LOGGER("Here we go logging on console!");
return 0;
}
We can discuss about the way the code is written (taken from the demos I mentioned), but how is initialized the dll and thread is:
#include "Logger.h"
#ifdef _WIN32
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
TheLog::InitLog();
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#endif
#include <thread>
void InitLog()
{
// Do the init taken from library demos
std::thread m_thread(LogListener);
}
void LogListener()
{
while(!bAppEnd)
{
std::cin>>str;
// change log behavior according to the user input
}
}
// to stop the thread when shutting down
void EndLog()
{
// retrieve thread thought id or some other way
thread.join();
}