25 Haz

C# Update A GUI Element From Another Thread

This examples shows how to update a user interface element from another thread. To do this, we must update to the user interface in user interface thread. Invoke method in Control class implements this task.

Sample Usage:

            //Usage 1
            txtSampleTextBox.Invoke(new Action(() => txtSampleTextBox.Text = "Sample Text"));

            //Usage 2
            txtSampleTextBox.Invoke((MethodInvoker)(() => txtSampleTextBox.Text = "Sample Text"));