I am trying my hardest to learn Cross/Multi Threading, but I am very confused on the concept. I made a sample application which is suppose to display i on a label.text via a thread. it's not working because I am trying to access a thread other than it was created on, I've researched a lot and I am still confused on Invoking, Delegation, etc... Here is my code:
private void s1_Click(object sender, EventArgs e)
{
Thread Thread1 = new Thread(new ThreadStart(Start1));
Thread1.Start();
}
public void Start1()
{
for (int i = 0; i < 1000; i++)
{
displaytext("Working.........", i);
Thread.Sleep(100);
}
}
public void displaytext(string thetext, int number)
{
t1.Text = thetext + " " + number;
}
What is a good way to get this working ? Any help is greatly appreciated. I am learning this for the love of programming.