在多线程asp.net [英] Multithreading in asp.net

查看:73
本文介绍了在多线程asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你有什么样的多线程问题要小心在asp.net?

What kind of multi-threading issues do you have to be careful for in asp.net?

推荐答案

这是有风险的,从一个ASP.NET页面的code-背后生成线程,因为工作进程将得到偶尔回收你的线程会死

It's risky to spawn threads from the code-behind of an ASP.NET page, because the worker process will get recycled occasionally and your thread will die.

如果您需要揭开序幕长期运行的进程作为在网页上用户行为的结果,最好的办法是在MSMQ下降的消息关闭,有一个独立的后台服务监控队列。因为它要完成的任务,该网页将其工作几乎立即完成该服务可以为长时间。你可以做到相同的事情与非同步调用Web方法,但不依赖于获得当Web方法完成工作的响应。从code-的背后,它需要一个快速的发射后不管。

If you need to kick off long-running processes as a result of user actions on web pages, your best bet is to drop a message off in MSMQ and have a separate background service monitoring the queue. The service could take as long as it wants to accomplish the task, and the web page would be finished with its work almost immediately. You could accomplish the same thing with an asynch call to a web method, but don't rely on getting the response when the web method is finished working. From code-behind, it needs to be a quick fire-and-forget.

这篇关于在多线程asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆