PC Review


Reply
Thread Tools Rate Thread

DataGridView DataTable(DataSet) and Thread safety

 
 
=?Utf-8?B?R2Vvcmdl?=
Guest
Posts: n/a
 
      19th Jun 2006
Hi,

I have a DataGridView, bounded to a DataTable which is populated/updated by
a OleDbDataAdapter (with OleDbConnection) to an Access Database. (Sounds
familiar to some of you ... I have posted a number of related questions
already.)

I want to have a worker thread starting to consume data from the DataTable.
Imagine that the DataTable contains a list of tasks. From the C# .NET
specification, DataTable "is safe for multithreaded read operations. You must
synchronize any write operations."

If the DataTable is managed programatically, e.g. not bound to a
DataGridView, the programming and testing shouldn't be too bad to create a
tread-safe application. However, my DataTable is bound to a DataGridView,
and I am concerned about the "random" updates made by the users. It's
probably wrong to assume any programatic/systematic behaviour by the users.

Is there a catch-all event between DataGridView and DataTable, such that I
can "lock" (or create a critical region) to control "Add", "Delete" and
"Update" to the DataTable? My worker thread will access the DataTable
directly, as programatic access to DataGridView is not allowed.

Or if anyone can advice me of any programming pattern for this type of set
up, I am all ears.

Thanks in advance.


--
George
 
Reply With Quote
 
 
 
 
Linda Liu [MSFT]
Guest
Posts: n/a
 
      20th Jun 2006
Hi George,

Thank you for posting.

I think when the BackgroundWorker is working, in order to prevent users
from adding, deleting or updating the data in the DataTable through the
DataGridView, you could disable the DataGridView.

You could set the Enabled property of the DataGridView to false before the
BackgroundWorker begins working and in the BackgroundWorker's
RunWorkerCompleted event handler set the DataGridView's Enabled property to
true.

Hope this helps.
If you have any other concerns, please don't hesitate to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Typed Dataset Thread Safety Dave T Microsoft ADO .NET 2 15th Feb 2008 06:29 PM
Thread safety of DataTable class - Filling on background thread OK? Alan Cobb Microsoft ADO .NET 9 1st Jul 2006 07:27 AM
Re: Dataset Thread Safety David Browne Microsoft ADO .NET 0 9th Sep 2004 08:43 PM
Re: Dataset Thread Safety Miha Markic [MVP C#] Microsoft ADO .NET 0 9th Sep 2004 07:59 PM
Thread Safety, dataset and dataview, ASP.NET Arthur Dzhelali Microsoft Dot NET 1 22nd Jul 2004 05:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:46 AM.