B
Bob Altman
Some classes (in particular, the Hashtable class) expose a SyncRoot
property. The help for that property states (in part):
Derived classes can provide their own synchronized version of the Hashtable
using the SyncRoot property. The synchronizing code must perform operations
on the SyncRoot of the Hashtable, not directly on the Hashtable. This
ensures proper operation of collections that are derived from other objects.
Specifically, it maintains proper synchronization with other threads that
might be simultaneously modifying the Hashtable object.
Is SyncRoot something that only classes derived from Hashtable need to worry
about? Is there some reason why my code that accesses a Hashtable needs to
synchronize with the Hashtable's SyncRoot property rather than with the
Hashtable itself? If so, why?
Is the following code incorrect for some reason?
' Class data
Dim m_hashTable as new HashTable()
Sub Something
SyncLock m_hashTable ' Should be m_hasTable.SyncLock ??????
<Do something>
End SyncLock
End Sub
TIA - Bob
property. The help for that property states (in part):
Derived classes can provide their own synchronized version of the Hashtable
using the SyncRoot property. The synchronizing code must perform operations
on the SyncRoot of the Hashtable, not directly on the Hashtable. This
ensures proper operation of collections that are derived from other objects.
Specifically, it maintains proper synchronization with other threads that
might be simultaneously modifying the Hashtable object.
Is SyncRoot something that only classes derived from Hashtable need to worry
about? Is there some reason why my code that accesses a Hashtable needs to
synchronize with the Hashtable's SyncRoot property rather than with the
Hashtable itself? If so, why?
Is the following code incorrect for some reason?
' Class data
Dim m_hashTable as new HashTable()
Sub Something
SyncLock m_hashTable ' Should be m_hasTable.SyncLock ??????
<Do something>
End SyncLock
End Sub
TIA - Bob