Beispiel #1
0
 public void appendText(string msg)
 {
     if (this.msgHst.InvokeRequired)
     {
         appendTextCallback d = new appendTextCallback(appendText);
         this.Invoke(d, new object[] { msg });
     }
     else
     {
         this.msgHst.AppendText(Environment.NewLine + msg);
     }
 }
 public void appendText(string msg)
 {
     if (this.msgHst.InvokeRequired)
     {
         appendTextCallback d = new appendTextCallback(appendText);
         this.Invoke(d, new object[] { msg });
     }
     else
     {
         this.msgHst.AppendText(Environment.NewLine + msg);
     }
 }
Beispiel #3
0
 private void AppendConsoleText(string text)
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (this.textBoxOutput.InvokeRequired)
     {
         appendTextCallback d = new appendTextCallback(AppendConsoleText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         this.textBoxOutput.AppendText(text);
     }
 }
        void appendText(Control control, string text)
        {
            if (control.InvokeRequired)
            {
                appendTextCallback d = new appendTextCallback(appendText);
                this.Invoke(d, new object[] { control, text });
            }
            else
            {
                string line = $"{DateTime.Now}: {text}\r\n";

                var method = control.GetType().GetMethod("AppendText");
                if (method != null)
                {
                    method.Invoke(control, new object[] { line });
                }
                method = control.GetType().GetMethod("Update");
                if (method != null)
                {
                    method.Invoke(control, null);
                }
            }
        }