TRACE hangs on multithread application
Posted on 2004-10-27
I have a multithread application that hangs on the TRACE command.
I've tried using CMutex and CCriticalSection objects to make sure more then one thread is not calling it at the same time, but it still hangs.
Here's the code:
void Log::LogData(CString Data, LogLevel Level)
CSingleLock singlelock(&blockingObj, TRUE);
static CStdioFile &file = InitializeLoggging();
static LogLevel MaxLogLevel = GetLevelOption();
static int QtyLogs = 0;
const int MaxQtyBeforeFlushing = 10;
if (Level > MaxLogLevel) return;
if (Level == LOG_ALWAYS || QtyLogs > MaxLogLevel)
QtyLogs = 0;
TRACE(Data); //********HANGS here
It doesn't hang right away. It usually hangs after it's called over 300 times.
If I comment out TRACE, then the program works just fine.
Anyone know how I can fix this?