与ASP.NET下载服务器如何实现长时间运行的同步请求? [英] Download server with ASP.NET how to accomplish long running synchronous requests?

查看:91
本文介绍了与ASP.NET下载服务器如何实现长时间运行的同步请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.NET应用程序是一个下载的应用程序(无页)其内容庞大的二进制文件(1-2 GB - > 1小时以上的下载时间与唤醒支持)的本地网络,并将它们传输到Web客户端(每一个请求 - >一个大的二元响应,所以没有text / html的响应)。我使用的是HTTP处理程序(ashx的),而不是处理请求(的.aspx)页面。使用共享缓存和生产者 - 消费者模式的主线程(从ASP.NET线程池)创建另一个线程和他们一起完成这项工作。在结束两个线程退出(返回到池)。

My ASP.NET application is a download application (no pages) which reads huge binary files (1-2 GB -> over 1 hours download time with resume support) from local network and stream them to web clients (each request -> one large binary response, so there's no text/html response at all). I use a HTTP Handler (.ashx) instead of a (.aspx) page for processing requests. Using a shared buffer and producer-consumer pattern main thread (from ASP.NET thread pool) creates another thread and together they accomplish the job. At the end both threads exit (get back to pool).

所以我长期运行的使用从线程池中的线程请求,一般不建议使用,但我没有任何网页在我的应用程序,它仍然使用线程ASP.NET线程池的一个瓶颈?

So I have long-running request using threads from thread pool which is not recommended generally but I don't have any page in my application, is it still a bottleneck using threads from ASP.NET thread pool ?

环境:服务器2008年64位,IIS 7.0和.NET 4.0

Environment: server 2008 64bit, IIS 7.0 and .NET 4.0

应采取哪些注意事项对于这种情况?
任何的评论是AP preciated。

What considerations should be taken for this scenario ? Any comment is appreciated.

推荐答案

正如我解释<一个href=\"http://stackoverflow.com/questions/4007863/how-to-create-threads-in-asp-net-pages-from-clr-thread-pool-instead-of-asp-net-po\">here,只需使用 IHttpAsyncHandler 实施ASHX推出自定义线程和asp.net线程中处理完成(因此将其返回到池)。使用此您可以启动每秒数千downoads无所剩无几asp.net线程池中的线程。 (如何,如果你想成为许多要求是另一个讨论的话题)

As I explained here, just use IHttpAsyncHandler implementation in ASHX to launch a custom thread and finish with processing inside asp.net thread (thus returning it to the pool). Using this you can initiate thousands of downoads per second without running out of asp.net thread pool threads. (How and if you wish to serve that many requests is another topic of discussion)

编辑:只是不要忘了叫 asyncRequestState.CompleteRequest()你的线程结束,否则asp.net不会知道你做服务该请求。

just don't forget to call asyncRequestState.CompleteRequest() at the end of your thread, otherwise asp.net won't know that you are done serving the request.

这篇关于与ASP.NET下载服务器如何实现长时间运行的同步请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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