Console Hangs after printf.
-
We are using Visual Studio .Net and dump a lot of debug info of our application to a console. Normally this is not a problem, however sometimes the console hangs and I cannot set the focus to the debugger anymore. And if I start the task manager, the whole system seems to hang. We do use multiple thread to log information to the console, so I created the threads with _beginthreadex instead of CreateThread, but that does not seem to make any difference. Any one got a clue why this might be happening?
-
We are using Visual Studio .Net and dump a lot of debug info of our application to a console. Normally this is not a problem, however sometimes the console hangs and I cannot set the focus to the debugger anymore. And if I start the task manager, the whole system seems to hang. We do use multiple thread to log information to the console, so I created the threads with _beginthreadex instead of CreateThread, but that does not seem to make any difference. Any one got a clue why this might be happening?
Maybe you need to make calls to printf thread safe, by using a CRITICAL_SECTION object.... void theadsafe_printf(char *lpzText) { EnterCriticalSection(&cs); printf("%s",lpzText); LeaveCriticalSection(&cs); } Use InitilizeCriticalSection() to create the cs object. and DeleteCriticalSection() when finished at the end of your app.