diff Implab/Diagnostics/TextFileListener.cs @ 205:8200ab154c8a v2

Added ResetState to RunnableComponent to reset in case of failure Added StateChanged event to IRunnable Renamed Promise.SUCCESS -> Promise.Success Added Promise.FromException Renamed Bundle -> PromiseAll in PromiseExtensions
author cin
date Tue, 25 Oct 2016 17:40:33 +0300
parents d45bdf510514
children 6efb77590b15
line wrap: on
line diff
--- a/Implab/Diagnostics/TextFileListener.cs	Tue Oct 18 17:49:54 2016 +0300
+++ b/Implab/Diagnostics/TextFileListener.cs	Tue Oct 25 17:40:33 2016 +0300
@@ -5,6 +5,7 @@
 namespace Implab.Diagnostics {
     public class TextFileListener: ListenerBase {
         readonly TextWriter m_textWriter;
+        readonly object m_lock = new object();
 
         public TextFileListener(string fileName) {
             m_textWriter = File.CreateText(fileName);
@@ -20,7 +21,7 @@
                 msg.Append("  ");
             msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, args.Channel, entry);
 
-            lock (m_textWriter) {
+            lock (m_lock) {
                 if (!IsDisposed) {
                     // тут гарантировано еще не освобожден m_textWriter
                     m_textWriter.WriteLine(msg);
@@ -35,7 +36,7 @@
             base.Dispose(disposing);
             if (disposing) {
                 // IsDisposed = true
-                lock (m_textWriter) {
+                lock (m_lock) {
                     Safe.Dispose(m_textWriter);
                 }
             }