/[RomCheater]/trunk/RomCheater.Logging/LogWriter.cs
ViewVC logotype

Diff of /trunk/RomCheater.Logging/LogWriter.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.Logging/LogWriter.cs	2012/06/03 15:15:51	246
+++ trunk/RomCheater.Logging/LogWriter.cs	2012/06/05 11:32:42	297
@@ -109,11 +109,18 @@
         }
         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 @@
             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(); }

 

  ViewVC Help
Powered by ViewVC 1.1.22