Thursday, July 17, 2014

Update UI from another thread in C#

We have two forms, and we have a thread in form 2, from form 2 we are sending the response, to form 1, based on response from form2,by using this response  we need to update the UI control (link label) in the form 1. But the response comes from a thread that runs in the background.

We have updated the label by using the following code.


control.Invoke(new Action(() => control.Text = "new text"));

No comments:

Post a Comment