-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: SitaramanM
Message 8 in Discussion

Hi   Suggest that u move th population of the hashtable logic from App start. A rough 
sketch is as folows   Make the hashtable private in a class Have a Property which 
retrieves this Hashtable Inside the property check whether the hashtable is 
nothing(which will be the case the first time).  If it is null populate this from 
Database. return the filled  hashtable If hashtable is not null(not first time 
hashtable access) then return the hashtable directly   Note : You can have this 
property as a shared property.  take care of synchronisation as there could(will) be 
multiple threads accessing this, as it is an asp.net application   Wherever you need 
to acces the hashtable(for filling up combos), call the type.property.  As it is a 
property and the first time it will populate from the database, you can write 
execption catch functions in the code itself   A rough code would be as follows   
Class MyHashTableClass
    Shared m_objLockObject As New Object
    Private Shared m_objHashTable As Hashtable     Public Shared ReadOnly Property 
MyHashtable() As Hashtable
        Get
            SyncLock (m_objLockObject)
                If  m_objHashTable Is Nothing Then                     m_objHashTable 
= New Hashtable
                    ' Write Code to populate HashTable from Database
                    ' Also ensure in the end that if the HashTable Count is still 
nothing
                    ' you can probably initialize the HashTable to Nothing.So that 
after the if condition is
                    ' finished, the check for nothing will result in an exception 
being thrown to the caller
                End If             if m_objHashTable Is Nothing  ' If it is still 
nothing                 ' throw Some Exception             else
                Return m_objHashTable
            End SyncLock
        End Get
    End Property
End Class   Module Module1     Sub Main2()         try            Dim x as 
hashTable=MyHashTableClass.MyHashTable         catch l_objException as Exception       
  'Handle Exception here         end try         'Use the HashTable     End sub End 
Module 
hth   regards,   sr

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to