protected void WriteLog()
{
try
{
if (Monitor.TryEnter(m_readerWriterLock))
{
try
{
if (string.IsNullOrWhiteSpace(m_fileName))
throw new NullReferenceException("No run-time log file name was specified");
using (StreamWriter writer = File.CreateText(m_fileName))
{
writer.WriteLine("{0}={1}", LastStartTimeKey, m_startTime.ToString(DateTimeFormat, CultureInfo.InvariantCulture));
writer.WriteLine("{0}={1}", LastStopTimeKey, m_stopTime.ToString(DateTimeFormat, CultureInfo.InvariantCulture));
writer.WriteLine("{0}={1}", LastRunningTimeKey, m_runningTime.ToString(DateTimeFormat, CultureInfo.InvariantCulture));
writer.Flush();
}
}
finally
{
Monitor.Exit(m_readerWriterLock);
}
}
}
catch (Exception ex)
{
OnProcessException(new InvalidOperationException("Failed to write run-time log: " + ex.Message, ex));
}
}