I am developing the web site, It consists of device name list and related Build Button. When one click the Build button the one pro开发者_如何学Pythoncess will run in server. When more than ten user click the Build button more processes will create at that server will hang. How can send all request from client to single process in server.
You could set up a WCF Windows service that internally has some kind of count of currently running processes and makes sure that there are never more than X threads each running one process. If you want exactly one, rather than just a limited amount, you don't even need to worry about the threads and can just halt other requests while it's processing one.
It might make it more difficult to give feedback to the users though if that's needed, since if one or more processes are queued, you can't immediately tell the user that the build has begun etc.
It sounds like you are spawning a process thread to do the build on the sever (I don't recommend this, as spawning threads in a ASP.Net application can be tricky). The easiest way to get around each request spawning a new thread would be to separate out your build process from the Asp.net web application. So:
- Move the build action to a Windows Service on the same machine.
- Use Windows Communication Foundation to expose the service entry point to the Asp.Net application
- Make the WCF instance a singleton instance, so that only one request can access it at a time. (This is the drawback of using only one thread.)
Your other option is to log the requests to a queue, and have a process (windows service maybe) monitor the queue, and process it one at a time. The drawback to this is that you won't get immediate results for the user. You'll need some way of notifying them when the process has finished, but you'll most likely have to do the same thing with the above solution too.
精彩评论