We have a build farm of forty Windows machines, allowing us to run forty builds simultaneously. However, these machines all share a common network space and at times we have found it necessary to limit the number of builds for performance reasons. We would like newly requested builds to sit in the queue and not be assigned a build host until the number of builds drops below a threshold.
We also realized such a solution could be used to stop incoming builds while letting existing builds complete, by setting the concurrent build limit to zero.. any requests made by users would then queue up until we opened the gate again.
I thought I came up with a solution, which worked on my test server, but the same code locked up my production server.