Hmm,
If you never remove the entries in the hashtable
(what you seem to do with the dataTables)
you can simplify it like...
Hashtable ht = new Hashtable();
Hashtable locks = new Hashtable();
private object GetLockObject( HashKey key)
{
object singleLock = locks[key];
if ( singleLock == null
Hi James,
I thought about that, but wanted to keep things simple ;)
Lets try this one, (very experimental)...
Hashtable ht = new Hashtable();
Hashtable locks = Hashtable.Synchronized( new Hashtable());
private object GetLockObject( HashKey key)
{
Object object = locks[key];
if ( object == n
lock
objects? ;-)
Best wishes
James
> -Original Message-
> From: Unmoderated discussion of advanced .NET topics.
> [mailto:[EMAIL PROTECTED] On Behalf Of Heath Ryan
> Sent: 22 July 2004 10:10
> To: [EMAIL PROTECTED]
> Subject: Re: [ADVANCED-DOTNET] Multithreaded hash tab
Hi James,
the synchronized Hashtable only syncs the hashTable
to sync also the db access, try this one...
Hashtable ht = new Hashtable();
public DataTable GetList( int a, int b, int c)
{
// lookup the dataTable
DataTable dt = (DataTable)ht[key];
if ( dt == null)
{
// since our last
: Wednesday, July 21, 2004 1:41 PM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Multithreaded hash table access
James Berry wrote:
> I'm sure there must be a really elegant way to do this. Any hints?
Yep. Look at System.Threading.ReaderWriterLock.
--
Steve
James Berry wrote:
> I'm sure there must be a really elegant way to do this. Any hints?
Yep. Look at System.Threading.ReaderWriterLock.
--
Steve Johnson
===
This list is hosted by DevelopMentorĀ® http://www.develop.com
Some .NET courses you may be interested in
I've got myself very confused, and I wonder if you guys can help a
little bit.
In my data-layer, I'm trying to implement some caching for a long (well
2-3 seconds) running database operation. I know when the results would
have changed, so when to re-run the stored proc. The stored proc takes
som