M
Moshe Peleg
Hi,
I'm developing a multiple threads application.
I need to log several events in the different threads into the same text
file.
The add_2_log function is very simle:
using (StreamWriter sw = new StreamWriter(log_file_name,true))
{
sw.Write (DateTime.Now.Date.Day.ToString().PadLeft(2, '0') +"/" +
DateTime.Now.Date.Month.ToString().PadLeft(2, '0') + "/" +
DateTime.Now.Date.Year.ToString() + "," + DateTime.Now.TimeOfDay.ToString()
+ "," + message + "," + code1.ToString() + "," + code2.ToString());
}
Do I need to add a Mutex in order to prevent thread trying to add a line
while file is already open for current ?
Thanks,
MP
I'm developing a multiple threads application.
I need to log several events in the different threads into the same text
file.
The add_2_log function is very simle:
using (StreamWriter sw = new StreamWriter(log_file_name,true))
{
sw.Write (DateTime.Now.Date.Day.ToString().PadLeft(2, '0') +"/" +
DateTime.Now.Date.Month.ToString().PadLeft(2, '0') + "/" +
DateTime.Now.Date.Year.ToString() + "," + DateTime.Now.TimeOfDay.ToString()
+ "," + message + "," + code1.ToString() + "," + code2.ToString());
}
Do I need to add a Mutex in order to prevent thread trying to add a line
while file is already open for current ?
Thanks,
MP