我的 ASP.NET Web 应用程序如何在同一进程内的新线程中生成程序?
我有一个 ASP.NET 应用程序需要运行命令行工具。我想在与应用程序池相同的进程下启动它,因此它会受到 IIS CPU 限制等的影响。如何才能做到这一点?
I have an ASP.NET application which needs to run a command-line tool. I want to start it under the same process as the application pool so it is subject to the IIS CPU throttling, etc. How can this be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这实际上是不可能的。想想当您使用命令行工具时这是如何工作的...命令行实际上只是一个外壳...当您启动应用程序时,它会启动自己的进程...实际上与外壳。如果您从 ASP.NET Web 应用程序启动该工具,也会发生同样的情况。
如果 CPU 占用是一个问题,您将必须想出不同的策略来限制应用程序。
This is not really possible. Think about how this works when you are using the command-line tool... the command line is really just a shell... when you luanch the app, it starts its own process... and in fact has nothing to do with the shell. The same thing would happen if you start the tool from an ASP.NET web app.
You'll have to come up with a different strategy for throttling the app if CPU hogging is an issue.
抱歉有点偏离主题,但我假设这个过程相当密集/长时间运行,因为您希望它受到限制。如果是这种情况,则不建议让 IIS 工作进程执行此工作。
请参阅此处了解原因为什么。
Sorry to be a little off topic but I'm assuming this process is rather intensive / long running seeing as you want it to be throttled. If this is the case, its not advisable to have the IIS worker process doing this work.
See Here for the reason why.