/[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

revision 246 by william, Sun Jun 3 15:15:51 2012 UTC revision 297 by william, Tue Jun 5 11:32:42 2012 UTC
# Line 109  namespace RomCheater.Logging Line 109  namespace RomCheater.Logging
109          }          }
110          private string StreamToString()          private string StreamToString()
111          {          {
112              string value = "";              try
113              sr = new StreamReader(ms);              {
114              sr.BaseStream.Seek(0, SeekOrigin.Begin);                  string value = "";
115              value = sr.ReadToEnd();                  sr = new StreamReader(ms);
116              return value;                  sr.BaseStream.Seek(0, SeekOrigin.Begin);
117                    value = sr.ReadToEnd();
118                    return value;
119                }
120                catch (Exception ex)
121                {
122                    return "";
123                }
124          }          }
125          public string GetLogText()          public string GetLogText()
126          {          {
# Line 193  namespace RomCheater.Logging Line 200  namespace RomCheater.Logging
200              public LogStream() : this(null) { }              public LogStream() : this(null) { }
201              public LogStream(LogWriter text) : base() { _text_writer = text; this.NewLine = "\n"; }              public LogStream(LogWriter text) : base() { _text_writer = text; this.NewLine = "\n"; }
202              private LogWriter _text_writer;              private LogWriter _text_writer;
203              private void _write(string message) { if (_text_writer == null) return; _text_writer.SetLogText(string.Format("{0}", message)); }              private void _write(string message)
204                {
205                    if (_text_writer == null) return;
206    
207                    if (message.EndsWith("\n"))
208                    {
209                        //_text_writer.SetLogText(string.Format("{0}", strMessage.ToString()));
210                        while (_text_writer.logupdater.IsBusy)
211                        {
212                            Application.DoEvents();
213                        }
214                        _text_writer.logupdater.RunWorkerAsync((string.Format("{0}", strMessage.ToString())));
215                        strMessage = new StringBuilder();
216                    }
217                    strMessage.Append(message);
218                }
219              #region Overriden Methods              #region Overriden Methods
220              public override Encoding Encoding { get { return Encoding.UTF8; } }              public override Encoding Encoding { get { return Encoding.UTF8; } }
221              public override void Write(char value) { base.Write(value); _write(value.ToString()); if (!_text_writer.BeginUpdate) _text_writer.EndLogUpdate(); }              public override void Write(char value) { base.Write(value); _write(value.ToString()); if (!_text_writer.BeginUpdate) _text_writer.EndLogUpdate(); }

Legend:
Removed from v.246  
changed lines
  Added in v.297

  ViewVC Help
Powered by ViewVC 1.1.22