List Info

Thread: C-Sharp (C#) Group: Synchronized Hashtable Singleton Question




C-Sharp (C#) Group: Synchronized Hashtable Singleton Question
user name
2006-12-14 15:34:57
I need to create a Hashtable that is a singleton and is
synchronized
for many readers and writers. I can, of course, create a
custom class
which has a hashtable as a member and lock the hashtable,
but that
would require me to create a wrapper function for each
hashtable
function I need. Instead, I've done this:

  class MyCache : Hashtable
  {
    private static MyCache Instance = new MyCache();

    public static Hashtable GetInstance()
    {
      return Synchronized(Instance);
    }
  }

I'm wondering if this is ideal (and safe, of course) or if
there is a
more appropriate way to do accomplish what I'm trying to do.

Thanks in advance . . .


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups-beta.google.com/group/C_Sharp?hl=en
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )