Help me please.
I translate the program from the console into Windows forms. After loading and displaying the form, the StartWork() function should work.
The code from console Main() I wrote in
private void Form1_Shown (object sender, EventArgs e)
{
StartWork();
}
But I'm faced with a problem, the form does not appear until the entire StartWork() function has completed. This takes a long time.
Then I drove StartWork() into a parallel thread, so as not to interfere with the display of the form.
private void Form1_Shown(object sender, EventArgs e)
{
Thread hread = new Thread(StartWork);
thread.Start();
}
But there was another problem: in the StartWork() function. I refer to Label.Text and I want to assign it a string, but I get an exception, that I can't do this because I get access to Label.Textnot from the thread where it was created.
How to solve this?