andrew4582

WriteOutput

Feb 23rd, 2011
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. void WriteOutput(string format,params object[] args) {
  2.             WriteOutput(string.Format(format,args));
  3.         }
  4.         /// <summary>
  5.         /// Writes output to a windows form using InvokeRequired property
  6.         /// </summary>
  7.         /// <param name="value">Data to output</param>
  8.         void WriteOutput(object value) {
  9.             string text = value == null ? string.Empty : value.ToString();
  10.             text += Environment.NewLine;
  11.  
  12.             Action<string> writeAction = (s) => richTextBox1.AppendText(s);
  13.             if(InvokeRequired)
  14.                 BeginInvoke(new Action<string>(writeAction),text);
  15.             else
  16.                 writeAction(text);
  17.         }
Advertisement
Add Comment
Please, Sign In to add comment