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 296 by william, Sun Jun 3 15:15:51 2012 UTC vs.
Revision 297 by william, Tue Jun 5 11:32:42 2012 UTC

--- trunk/RomCheater.Logging/LogWriter.cs	2012/06/05 10:52:57	296
+++ trunk/RomCheater.Logging/LogWriter.cs	2012/06/05 11:32:42	297
@@ -109,11 +109,18 @@ namespace RomCheater.Logging
         }
         private string StreamToString()
         {
-            string value = "";
-            sr = new StreamReader(ms);
-            sr.BaseStream.Seek(0, SeekOrigin.Begin);
-            value = sr.ReadToEnd();
-            return value;
+            try
+            {
+                string value = "";
+                sr = new StreamReader(ms);
+                sr.BaseStream.Seek(0, SeekOrigin.Begin);
+                value = sr.ReadToEnd();
+                return value;
+            }
+            catch (Exception ex)
+            {
+                return "";
+            }
         }
         public string GetLogText()
         {
@@ -193,7 +200,22 @@ namespace RomCheater.Logging
             public LogStream() : this(null) { }
             public LogStream(LogWriter text) : base() { _text_writer = text; this.NewLine = "\n"; }
             private LogWriter _text_writer;
-            private void _write(string message) { if (_text_writer == null) return; _text_writer.SetLogText(string.Format("{0}", message)); }
+            private void _write(string message)
+            {
+                if (_text_writer == null) return;
+
+                if (message.EndsWith("\n"))
+                {
+                    //_text_writer.SetLogText(string.Format("{0}", strMessage.ToString()));
+                    while (_text_writer.logupdater.IsBusy)
+                    {
+                        Application.DoEvents();
+                    }
+                    _text_writer.logupdater.RunWorkerAsync((string.Format("{0}", strMessage.ToString())));
+                    strMessage = new StringBuilder();
+                }
+                strMessage.Append(message);
+            }
             #region Overriden Methods
             public override Encoding Encoding { get { return Encoding.UTF8; } }
             public override void Write(char value) { base.Write(value); _write(value.ToString()); if (!_text_writer.BeginUpdate) _text_writer.EndLogUpdate(); }