Exemple #1
0
 private void UpdateTextBox(string newText)
 {
     if (txtResult.InvokeRequired)
     {
         updateTextBoxDelegate del = new updateTextBoxDelegate(UpdateTextBox);
         txtResult.Invoke(del, new object[] { newText });
     }
     else
     {
         txtResult.Text = newText;
     }
 }
Exemple #2
0
 public void threadSafeTextBoxUpdate(TextBox txtbx, string txt, Boolean append)
 {
     if (txtbx.InvokeRequired)
     {
         updateTextBoxDelegate d = new updateTextBoxDelegate(updateTextBoxFunction);
         this.Invoke(d, new object[] { txtbx, txt, append });
     }
     else
     {
         if (append)
         {
             txtbx.AppendText(txt);
             txtbx.Update();
         }
         else
         {
             txtbx.Text = txt;
             txtbx.Update();
         }
     }
 }
 private void updateTextBox(string newText, TextBox l)
 {
     if (l.InvokeRequired)
     {
         // this is worker thread
         updateTextBoxDelegate del = new updateTextBoxDelegate(updateTextBox);
         l.Invoke(del, new object[] { newText, l });
     }
     else
     {
         // this is UI thread
         l.Text = l.Text + newText;
     }
 }