Hi all!
In my app I implemented a separate worker thread that handles network
communication using Net.Sockets. It needs to make updates to a
DataTable object, which is displayed to the user by a DataGrid
control. The DataTable object is a 'public static' field instantiated
within context of the main thread.

The problem is that if I add a column to the DataTable from within the
worker thread (eg. different thread than where the DataTable and
DataGrid reside in), all columns suddenly disappear from the DataGrid
view for some reason;

Controller.dataTable.Columns.Add(new DataColumn("TestColumn"));

If I move this code to the main thread, it works fine. After adding
new column, I looked at dataTable with debugger and it seemed fine. So
the culprit must be the DataGrid control. Do I need some kind of
thread synchronization?

Re: Making updates to DataTable/DataGrid from within another thread by ClayB

ClayB
Mon Aug 09 04:44:37 CDT 2004

Here is a thread discussing a similar problem. Maybe something like this
will help in your case.

http://www.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=uPmHvVZVEHA.1048%40TK2MSFTNGP09.phx.gbl&rnum=1&prev=/groups%3Fas_q%3D%2522clay%2520burch%2522%26as_epq%3Dreal%2520time%2520updates%26safe%3Dimages%26ie%3DUTF-8%26lr%3D%26hl%3Den


=================================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools

"Dr. Len" <len@isp.com> wrote in message
news:1obch0lc7ceuqjfe7mfiacbsp4p5t6im28@4ax.com...
> Hi all!
> In my app I implemented a separate worker thread that handles network
> communication using Net.Sockets. It needs to make updates to a
> DataTable object, which is displayed to the user by a DataGrid
> control. The DataTable object is a 'public static' field instantiated
> within context of the main thread.
>
> The problem is that if I add a column to the DataTable from within the
> worker thread (eg. different thread than where the DataTable and
> DataGrid reside in), all columns suddenly disappear from the DataGrid
> view for some reason;
>
> Controller.dataTable.Columns.Add(new DataColumn("TestColumn"));
>
> If I move this code to the main thread, it works fine. After adding
> new column, I looked at dataTable with debugger and it seemed fine. So
> the culprit must be the DataGrid control. Do I need some kind of
> thread synchronization?