threads and datatables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an windows form that displays information from a datatable using a
datagrid. The datatable is maintained from a seperate thread. Once a new row
is added the form freezes.

Any ideas ?
 
What is happening I would guess is that you are using databinding (you don't explicitly say that).

When you add the new row, the datatable generates an event to the datagrid (so it can update the view) - this event will be executed on the thread that added the row, i.e. the non-UI thread. Therefore you are breaking the golden rule of Windows Forms - thou shalt not update the UI from a worker thread. You need to get the UI thread to add the row by passing the info to it using datagrid.BeginInvoke

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

I have an windows form that displays information from a datatable using a
datagrid. The datatable is maintained from a seperate thread. Once a new row
is added the form freezes.

Any ideas ?
 
Back
Top