Hi,
I have three classes, each one has distinct role apart from this there is main.
from main the flows goes as follows
main-->CTestForLog(cr eate and run the thread)
and in thread flows goes as.
CLogger-->CFileWriter(si ngleton class and it writes to a file )
Means In thread funstion i have instance of CLogger class which calls the write method of CFileWriter class which is a singleton and responsible to write to a single file
the objective of application is multiple insatnces of CLogger so that all logs goes to a single file.
Where
mhmut = CreateMutex(NUL L,TRUE,NULL);
but the problem is that i am getting
Unhandled exception at 0x00421213 in Logger.exe: 0xC0000005: Access violation reading location 0xcccccccc.
and the application terminate.
pls. help me
I have three classes, each one has distinct role apart from this there is main.
from main the flows goes as follows
main-->CTestForLog(cr eate and run the thread)
and in thread flows goes as.
CLogger-->CFileWriter(si ngleton class and it writes to a file )
Means In thread funstion i have instance of CLogger class which calls the write method of CFileWriter class which is a singleton and responsible to write to a single file
the objective of application is multiple insatnces of CLogger so that all logs goes to a single file.
Code:
void CFileWriter::setFileContent(std::string astring) { DWORD nBytes; DWORD nWrites; nBytes = (DWORD)astring.length(); WaitForSingleObject(mhmut,INFINITE); LPCVOID temp = astring.c_str(); std::cout<<astring<<"\n"; WriteFile(mhfile,temp,nBytes,&nWrites,NULL); ReleaseMutex(mhmut); }
mhmut = CreateMutex(NUL L,TRUE,NULL);
but the problem is that i am getting
Unhandled exception at 0x00421213 in Logger.exe: 0xC0000005: Access violation reading location 0xcccccccc.
and the application terminate.
pls. help me
Comment