Fastest way for writing in text files in a MultiThreading application
Posted on 2003-11-13
I have an application that logs information into a text file, there are multiple threads in the file logging information. Sometimes when the application starts a high load, some entries are not logged in the file, but I have tested that errors happens only in the logging, because the missed entries are recorded in a database, for example.
so, I'm looking for the fastest way to lock this file and save the information, by now I'm using CreateFile like this, without sharing for locking automatically :
m_hFile = CreateFile
The file is created hourly, in the name of the file is the date including current hour.
Visual C++ 6.0
Windows 2000 AS
What is the better way for doing this? maybe with fopen, fprintf or fwrite, with mutexes or a critical section?
thanks in advance