E
Evgenia
I'm sorry for an uncertain question, but I can't ask it better.
I've got a web-service, which method invokes very-very often, so I have to
battle for every millisecond.
Method does next:
try
{
/* main code here */
lock(this) // writing in text log file
{
FileInfo f = new FileInfo(file name); // file name contains date and time
to an hour
StreamWriter writer = f.AppendText();
writer.WriteLine(logline);
writer.Close();
}
}
catch (Exception ex)
{
lock(this) // writing in text error-log file
{
FileInfo f = new FileInfo(file name); // file name contains date and time
to an millisecond
StreamWriter writer = f.AppendText();
writer.WriteLine(errorline);
writer.Close();
}
}
Tha most often exception is:
The process cannot access the file ... because it is being used by another
process
I should think out how to accelerate this scheme and minimize the quantity
of exception as far as possible, and at the same time not lose any log
recording and finale speed of method's execution.
What can I do?
Please, advise, how should such tasks be solved in systems with high load.
Thank you for any help in advance and sorry for my bad english.
I've got a web-service, which method invokes very-very often, so I have to
battle for every millisecond.
Method does next:
try
{
/* main code here */
lock(this) // writing in text log file
{
FileInfo f = new FileInfo(file name); // file name contains date and time
to an hour
StreamWriter writer = f.AppendText();
writer.WriteLine(logline);
writer.Close();
}
}
catch (Exception ex)
{
lock(this) // writing in text error-log file
{
FileInfo f = new FileInfo(file name); // file name contains date and time
to an millisecond
StreamWriter writer = f.AppendText();
writer.WriteLine(errorline);
writer.Close();
}
}
Tha most often exception is:
The process cannot access the file ... because it is being used by another
process
I should think out how to accelerate this scheme and minimize the quantity
of exception as far as possible, and at the same time not lose any log
recording and finale speed of method's execution.
What can I do?
Please, advise, how should such tasks be solved in systems with high load.
Thank you for any help in advance and sorry for my bad english.