I'm currently working on an app where players can enter a tournament to play and there are no limitations on how many players can play the same tournament. Players are using React.js client with signalR and they are invoking the hub method for registration and unregistration. For player storage, I use in a tournament object a List so when a player is registered in a tournament it is added to a list and when is unregistered it is removed form the list in two different methods. Do I need a lock and how should it be implemented?
Asked
Active
Viewed 105 times
1 Answers
0
Two or more players can enter the tournament in the exact same moment.
Usually sentences which contain plural subjects accessing/sharing one or more object should give an indication of concurrency.
Locking an object can be done in multiple ways. Here are few solutions:
- Use thread safe collections (ex. ConcurrentBag)
- Use ReaderWritterLock
- lock statement. example

FGBfye
- 60
- 5