473,386 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

.net sync

i have an array that i want all threads to be able to READ from
concurrently, however, at times i want to UPDATE the array. at which point i
want all threads that use it to block when they try to read from the array.
currently i do this by wrapping ALL READ AND WRITE access to the array in a
lock("foobar"){} this prevernts threads from reading from the array while it
is being written to however it ALSO keeps more then one thread from reading
the array at a time. how to solve this so that multiple threads can read the
array at the same time but whent he array is being updated all threads that
want to read from it block until it updates, and so that the code to update
the array blocks until no thread is reading from the array before it starts
to update it?
Jul 21 '05 #1
1 1430
That is exactly the problem the System.Threading.ReaderWriterLock class
is supposed to solve.

Daniel wrote:
i have an array that i want all threads to be able to READ from
concurrently, however, at times i want to UPDATE the array. at which point i
want all threads that use it to block when they try to read from the array.
currently i do this by wrapping ALL READ AND WRITE access to the array in a
lock("foobar"){} this prevernts threads from reading from the array while it
is being written to however it ALSO keeps more then one thread from reading
the array at a time. how to solve this so that multiple threads can read the
array at the same time but whent he array is being updated all threads that
want to read from it block until it updates, and so that the code to update
the array blocks until no thread is reading from the array before it starts
to update it?

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jason Gyetko | last post by:
I have a software application with an Access front end and an Access backend to house the data. Recently I converted the backend to MySQL. The Access frontend works fine connecting to the MySQL...
1
by: Rob F. | last post by:
I have tried to set up log shipping for one of our databases - first time. Using EM I was able to create the job and maintenance plan sucessfully. I wasn't able to find any errors in any logs. ...
1
by: kartik | last post by:
I open an fstream in read-only mode, read till the end, then try to sync() before seeking to position 0 & reading again. But the sync fails. I discovered that clear()ing the stream before the sync...
0
by: JG | last post by:
What are the implications of setting the "--bdb-no-sync" flag when using the BDB storage engine. There isn't alot of documentation on this. I have searched google and docs. If there is a...
3
by: Ryan Liu | last post by:
Hi, What does ArrayList.Synchronized really do for an ArrayList? Is that equal to add lock(this) for all its public methods and properties? Not just for Add()/Insert()/Remvoe()/Count, but also...
7
by: Ole | last post by:
Hi, I'm going to develop a socket communication between an instrument (running CE 5.0 with Compact Fraework V2) and a PC. As the instrument should only connect to one PC at a time I believe that...
3
by: iKiLL | last post by:
Hi , I am trying to debug a problem with a Windows Mobile Application. I need the PDA to Sync(I have writen the sync process myself using a web service) using GPRS while Debugging from the VS...
7
by: john | last post by:
I am reading TC++PL3 and on page 644 it is mentioned: "Flushing an istream is done using sync(). This cannot always be done right. For some kinds of streams, we would have to reread characters...
2
by: Jorge | last post by:
Either a synchronous call isn't what I believe it to be, or there's a bug in FF3 : IOW : Why does the onclick handler of the button "SYNC" return (in FF3) before the XHR has completed ? Click...
3
by: OldBirdman | last post by:
Help & Support - Start syncing 1. Click to open Sync Center - OK I did that 2. On the toolbar, click Sync All - There is NO toolbar So under Tasks, I click "Set up new sync partnerships". ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.