For Programmers: Free Programming Magazines  


Home > Archive > C# > June 2004 > Multithreading and DataSet, DataTable, DataRow









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Multithreading and DataSet, DataTable, DataRow
Thomas Gasser

2004-06-09, 6:19 pm

Hello,

if you have defined a DataSet in the HttpApplicationState which is
shared by all current users ...

what I have to do, to make the Dataset, DataTables and DataRows
thread-safe?

Following my assumptions:

1) If I change a Row:
lock (datarow)
{
datarow["xy"] = value;
}

2) If I add Rows
lock (datatable)
{
datatable.Rows.Add(..)
}

3) If I use the Fill method
lock (datatable)
{
adpt.Fill(datatable);
// what happens with changed or currently locked datarows?
// e.g: process 1 locks row X of datatable A
thread 2 wants to lock datatable A, is process 2 waiting for process 1
to unlock row A

}

4) If I make AcceptChanges to DataTable or DataRow
lock (datatable)
{
datatable.AcceptChanges();
}

5) For datatable.Remove (lock datatable)
6) For datarow.Delete() (lock datarow)
7) For dataset.Tables.Add() (lock dataset)

8) If I do a datatable.select(...) what a have to do to make it
thread-safe?

Is this correct or completly wrong?

in your applicatoin writes on rows can only be done by one user at the
same time, reading should be possible for all users "at the same
time".

Maybe yo have some answers...

Thank u!
Thomas Gasser
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com