如何使用IHTTPAsyncHandler?
想象一下,我有一些代码需要从文件的开头到结尾读取,如下所示:
while(sw.readline != null)
{
}
我希望这是完全异步的。 当从 IHTTPAsyncHandler 派生时,这段代码会去哪里?获取每行内容的代码会去哪里?
Imagine I have some code to read from the start to end of a file like so:
while(sw.readline != null)
{
}
I want this to be fully asynchronous. When deriving from IHTTPAsyncHandler, where would this code go and where would would the code to get the content of each line go?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近向 ASP.NET 页面添加了一些异步进程,以便在用户等待结果时允许一些长时间运行的进程发生。 我发现 IHTTPAsyncHandler 相当不够。 它所做的只是允许您在页面开始处理时分离一个新线程。 您仍然需要创建自己的线程并创建 AsyncRequestResult。
相反,我最终只是在代码隐藏中使用普通线程,更加简洁:
I recently added some asynchronous processes to my ASP.NET pages in order to allow some long-running processes to take place while the user waited for the results. I found the IHTTPAsyncHandler quite inadequate. All it does is allow you to spin off a new thread while the page begins processing. You still have to make your own thread and create a AsyncRequestResult.
Instead I ended up just using a normal thread in my codebehind instead, much more succinct: