.Net 2.0 Pb with multi threads and DataSet dataBinding

S

Steve B.

Hi,

I've build an application that use several threads in background.

These threads are managed by a manager object and store control data in a
dataset.

I've also bound the DataSet to a GridView control.
When I run the application, althought I "see" the gridview control to be
filled and updated byt the actual values filles from the background threads,
the application is blocked.

So my question is : Is the dataset thread safe ?
If not, and in a more general manner, are databounded controls thread safe ?

Thanks in advance,
Steve
 
P

Patrick Steele

I've build an application that use several threads in background.

These threads are managed by a manager object and store control data in a
dataset.

I've also bound the DataSet to a GridView control.
When I run the application, althought I "see" the gridview control to be
filled and updated byt the actual values filles from the background threads,
the application is blocked.

So my question is : Is the dataset thread safe ?

The DataSet class is threadsafe for read operations. You must
synchornize any writes to a DataSet.
 
S

Steve B.

I created in my project a component that manage all threads.
When I require modifying the property of a DataRow, I use the Form.Invoke()
method in order to make the dataset modify only by the UI thread.

This workaround solved my problem, however, I need to have one
"SetXXXProperty" method for each property of my row (I'm not sure reflexion
will be fast enough since I've a lot of set operations per seconds.

According that, do you think I should better continue in this way (delegate
sets to the ui thread) or should I use a "lock" statement on the dataTABLE
each time I need to update it ?

Thanks,
Steve
 
P

Patrick Steele

I created in my project a component that manage all threads.
When I require modifying the property of a DataRow, I use the Form.Invoke()
method in order to make the dataset modify only by the UI thread.

This workaround solved my problem, however, I need to have one
"SetXXXProperty" method for each property of my row (I'm not sure reflexion
will be fast enough since I've a lot of set operations per seconds.

According that, do you think I should better continue in this way (delegate
sets to the ui thread) or should I use a "lock" statement on the dataTABLE
each time I need to update it ?

If there's a possibility of multiple threads updating the datatable at
the same time, I would use a lock.
 
S

Steve B.

Since I update my table in the UI thread (through control.invoke method),
I'm sure only one thread will update my datatable...
It's probably not the best way, but it works:)

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top