Bonjour

I am using WCF to make a chat application - I dont think the fact I'm using WCF is relevant for this particular question but just thought I would mention it in case there is something special about the way WCF does threading that I dont know about.

So I have my WCF service that runs on a server and a WPF app that acts as the WCF client - each time a new client signs in or out it updates the server WCF service to let it know that it has changed status. The server then updates a list to either add or remove the user, so this list basically represents who is online at any one time. The list is declared in the core server class like so:
vb.net Code:
  1. Private Shared List(Of ChatUser)

So, I have a method in my server side that is called whenever a user needs to be added to this list and originally I thought I could have some issues because while the server might be looping through this list to find out who is online, another user might have signed out and the list would therefore be modified while the server was looping through it which would cause an exception. So I added the following to the start of the method that removes a user from the list:
vb.net Code:
  1. SyncLock New Object
and I havent had any problems... but I'm still not totally convinced that this will completely solve the issue. So would creating a Property give me a bit of extra safety? Assuming I always used the property to access the list in my code.
Like this:
vb.net Code:
  1. Private Shared Property CurrentClientList() As List(Of ChatUser)
  2.         Get
  3.             SyncLock New Object
  4.                 Return _CurrentClientList
  5.             End SyncLock
  6.         End Get
  7.         Set(ByVal value As List(Of ChatUser))
  8.             SyncLock New Object
  9.                 _CurrentClientList = value
  10.             End SyncLock
  11.         End Set
  12. End Property
Also, am I actually using SyncLock correctly? I mean should I be referring to a shared object that all of the threads can access rather than just doing New Object each time or does it not make a difference?

Thanks
Chris