Threading in Windows Forms

  • Thread starter Thread starter Guogang
  • Start date Start date
G

Guogang

Hi,

According to documentation, windows forms are single threaded.

I tried to call a Windows Forms method from a new thread as following. Seems
there is no problem update control across thread. I can see my list view
updated while the function "Update" is still running.

Is there something will go wrong potentially without using "BeginInvoke"?

//C# code, .Net Framework 1.1
Thread t = new Thread(new ThreadStart(Update));
....

private void Update()
{
ListViewItem item;
...
myListView.Items.Add(item);
Thread.Sleep(10000);
}

Thanks,
Guogang
 
There's lots of things that could potentially go wrong, and they never seem
to happen until after your customer has deployed the application. :)

Seriously, make sure you use Invoke/BeginInvoke for these types of things.
 
Back
Top