WCF return values and threadsafe locks on generic collections
am 21.10.2007 18:41:03 von herbertHow do I handle a generic collection to be sent from the server to the client
if that collection must be accessed threadsafe ? my server object must be
singleton.
my idea of the singleton is:
Private Shared mControlStations As New List(Of ControlStation)
Private Shared mLockControlStations As New Object 'for locked access
Function GetListOfControlStations() As List(Of ControlStation) _
Implements Contracts.IxxxContract.GetListOfControlStations
SyncLock mLockControlStations 'lock access to control stations list
'create a copy of the list(of T)
End SyncLock
Return ... 'return the list(of T)
End Function
Is there a better way than to create a deep copy ?
thank you very much. herbert