I need 2 labels in my form to be updated every 1 second, so I made a thread in load
of Form
:
Thread threadUpdate = new Thread(new ThreadStart(UpdateState));
threadUpdate.Start();
And my UpdateState
method is found as follows:
private void UpdateState()
{
ChangeAutoRestartValue();
ChangeShellValue();
Thread.Sleep(1000);
UpdateState();
}
Both methods within my UpdateState
are to update the specific labels, but since it is not the main thread that is updating the value of these labels, it does not allow this to be done.
How can I update the value of these labels using this thread to update their values?