Cross thread update Windows Form


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. delegate void updateLabelTextDelegate(string newText);
  2. private void updateLabelText(string newText)
  3. {
  4. if (lblMessage.InvokeRequired) //lblMessage UI ID
  5. {
  6. // this is worker thread
  7. updateLabelTextDelegate del = new updateLabelTextDelegate(updateLabelText);
  8. lblMessage.Invoke(del, new object[] { newText });
  9. }
  10. else
  11. {
  12. // this is UI thread
  13. lblMessage.Text = newText;
  14. }
  15. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.