all groups > dotnet windows forms > february 2007 >
You're in the

dotnet windows forms

group:

.Net 2.0 Pb with multi threads and DataSet dataBinding


.Net 2.0 Pb with multi threads and DataSet dataBinding Steve B.
2/26/2007 4:01:32 PM
dotnet windows forms: 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

Re: .Net 2.0 Pb with multi threads and DataSet dataBinding Patrick Steele
2/26/2007 5:46:57 PM
In article <eMg3SdbWHHA.480@TK2MSFTNGP02.phx.gbl>,
steve_beauge@com.msn.swap says...
[quoted text, click to view]

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

--
Patrick Steele
Re: .Net 2.0 Pb with multi threads and DataSet dataBinding Steve B.
2/27/2007 12:00:00 AM
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

"Patrick Steele" <patrick@mvps.org> a écrit dans le message de news:
MPG.204d2d67bf8b60e198971c@msnews.microsoft.com...
[quoted text, click to view]

Re: .Net 2.0 Pb with multi threads and DataSet dataBinding Patrick Steele
3/5/2007 9:35:52 PM
In article <uva96#kWHHA.4240@TK2MSFTNGP06.phx.gbl>,
steve_beauge@com.msn.swap says...
[quoted text, click to view]

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

--
Patrick Steele
Re: .Net 2.0 Pb with multi threads and DataSet dataBinding Steve B.
3/6/2007 12:00:00 AM
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

"Patrick Steele" <patrick@mvps.org> a écrit dans le message de news:
MPG.20569d96826f35fc989728@msnews.microsoft.com...
[quoted text, click to view]

AddThis Social Bookmark Button