.NETGURU
Dataset Thread Safety
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.adonet.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

edwwsw (VIP)
$ Thread Safety
$ This type is safe for multithreaded read operations. You must synchronize
any write operations.

I am trying to figure out exactly what this statement means.

So if I have multiple threads accessing an ADO.Net dataset and only one of
those threads ever writes to the database but multiple threads are reading
from it. Do I have to write code to synchronize access to the ADO.Net
dataset or is that built into the Ado.Net dataset? Basically are updates
atomic and are the events guarentteed to fire in the UI thread?

If synchronization code needs to be written, how does this effect data
binding to grid controls where access to the data is outside of programmer
control, hence can not have synchronization code injected (note the grid
control is in read only mode)?
Reply to this message...
 
    
Miha Markic [MVP C#]
"edwwsw" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Nothing is guaranteed. Only that you'll get in trouble doing these kind oh
hacks :-)

[Original message clipped]

If the dataset is bound to a data consumer such as grid, every change has to
happen inside the UI thread (the thread the control was created in).

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Reply to this message...
 
    
David Browne
"edwwsw" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Updates are not atomic, and you must have exclusive access to the DataSet to
update it.

But winforms events are guaranteed to fire in the UI thread. When a user
clicks a button or hits a key this queues a message in the window's message
queue. The UI thread dequeues these messages one at a time and dispatches
to the event handler. So UI events are guaranteed to run on the UI thread,
and are therefore serialized.

David

Reply to this message...
 
    
edwwsw (VIP)
I think Miha confirmed one of my suspicions. When the dataset is bound to a
UI control – all updates to the database must be made in same thread the UI
component is in.

The eventing I was referring to in my post was not the UI eventing but the
eventing issued from the dataset. When the dataset is changed in any way, it
issues events about the changes. Any UI control that is bound to a dataset
listens for these changes and updates itself based on them.

If the update to a dataset occurs in a different thread from the UI thread
then the delegate for updating the UI will be launched in the non UI thread.
The delegate for data bound control is most likely directly updating the UI
control and hence this creates a situation where multiple threads are
updating the same UI component – not good.

"David Browne" wrote:

[Original message clipped]

Reply to this message...
 
 
System.Data.DataSet




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification