ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater.Logging/LogWriter.cs
(Generate patch)

Comparing trunk/RomCheater.Logging/LogWriter.cs (file contents):
Revision 772 by william, Thu Jun 20 21:41:37 2013 UTC vs.
Revision 773 by william, Thu Jun 20 22:03:10 2013 UTC

--- trunk/RomCheater.Logging/LogWriter.cs	2013/06/20 21:41:37	772
+++ trunk/RomCheater.Logging/LogWriter.cs	2013/06/20 22:03:10	773
@@ -56,18 +56,22 @@ namespace RomCheater.Logging
             set
             {
                 _RedirectConsoleOutput = value;
-                if (value) { Console.SetOut(this.Log); }
+                if (value) 
+                {
+                    Console.SetOut(TextWriter.Synchronized(this.Log)); 
+                }
                 else
                 {
-                    Stream stream = Console.OpenStandardOutput(0x100);
-                    TextWriter writer = null;
-                    if (stream == Stream.Null) { writer = TextWriter.Synchronized(StreamWriter.Null); }
-                    Encoding encoding = this.Log.Encoding;
-                    StreamWriter writer2 = new StreamWriter(stream, encoding, 0x100);
-                    //writer2.HaveWrittenPreamble = true;
-                    writer2.AutoFlush = true;
-                    writer = TextWriter.Synchronized(writer2);
-                    Console.SetOut(writer);
+                    //Stream stream = Console.OpenStandardOutput(0x100);
+                    //TextWriter writer = null;
+                    //if (stream == Stream.Null) { writer = TextWriter.Synchronized(StreamWriter.Null); }
+                    //Encoding encoding = this.Log.Encoding;
+                    //StreamWriter writer2 = new StreamWriter(stream, encoding, 0x100);
+                    ////writer2.HaveWrittenPreamble = true;
+                    //writer2.AutoFlush = true;
+                    //writer = TextWriter.Synchronized(writer2);
+                    //Console.SetOut(writer);
+                    //Console.SetOut(this.Log);
                 }
             }
         }
@@ -96,17 +100,18 @@ namespace RomCheater.Logging
             }
             else
             {
-                if (txtLog.IsDisposed)
+                if (this.IsDisposed || this.txtLog.IsDisposed)
                 {
                     return;
                 }
                 try
                 {
+                    var text = this.Text;
                     txtLog.AppendText(value);
                 }
                 catch (Exception)
                 {
-                }
+                }                   
                 //if (AutoScroll)
                 //{
                 //    txtLog.SelectionStart = 0;