Posted By

falconzy on 11/25/10


Tagged

form windows update


Versions (?)

Cross thread update Windows Form


 / Published in: C#
 

  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  

You need to login to post a comment.