I have a game server than can take requests from a user. A user can request to place pieces. The place method then spawns some async httpwebrequests (with timeouts) to find out if the placement was correct. I want a lock that will be locked when the server receives the placement request, and will be unlocked by the web callback. I would use a ReaderWriterLock, but that only works if I stay in the same thread, and the web request callbacks occur on different threads. Is there another lock I should use?
Share
You can use a semaphore. The locking thread acquires a permit. The async thread releases a permit. Semaphores are nifty because they aren’t bound to individual threads.