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 check
    // the dataTable might be put already
    // by another thread, so lock and lookup again
    lock( ht.SynRoot)
    {
      dt = (DataTable)ht[key];
      if ( dt == null)
      {
        // insert new DataTable
        dt = GetListLong(a, b, c);
        ht[key] = dt;
        // finished get out!
        return dt;
      }
    }
  }

  // dataTable exists, but is it still valid?
  if ( Expired( dt))
  {
    // since our last check
    // an updated dataTable might be put already
    // by another thread, so lock and lookup again
    lock( ht.SynRoot)
    {
      dt = (DataTable)ht[key];
      if ( Expired( dt))
      {
        // insert updated DataTable
        dt = GetListLong(a, b, c);
        ht[key] = dt;
      }
    }
  }

  return dt;
}

HTH
// Ryan


-------------------------------------
The information included in this message is personal and/or confidential and
intended exclusively for the addressees as stated. This message and/or the
accompanying documents may contain confidential information and should be
handled accordingly. If you are not the intended reader of this message, we
urgently request that you notify Centric immediately and that you delete
this e-mail and any copies of it from your system and destroy any printouts
immediately.
It is forbidden to distribute, reproduce, use or disclose the information in
this e-mail to third parties without obtaining prior permission from
Centric. We expressly point out that there are risks associated with the use
of e-mail. Centric and the companies within the group shall not accept any
liability whatsoever for damage resulting from the use of e-mail. Legally
binding obligations can only arise for Centric by means of a written
instrument, signed by an authorized representative of Centric.
-------------------------------------

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to