指示浏览器在继续处理时不要等待更多内容 [英] Instruct the browser not to wait for more content while processing continues

查看:66
本文介绍了指示浏览器在继续处理时不要等待更多内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何指示浏览器不要期望其他内容出现?Kinda就像服务器上所说的:我得到了我所需要的,您不需要等待我完成页面的处理".

How do I instruct the browser not to expect any more content to be coming down the line? Kinda like the server saying "I got what I need, you don’t need to wait while I finish the processing of the page".

我有一个服务器端任务,当某个页面被点击时启动.该任务可能很耗时,但是呈现的HTML始终是相同的,例如感谢您启动任务"消息.

I have a server-side task, which is initiated when a certain page is hit. The task may be time-consuming, but the rendered HTML will always be the same, i.e. like a "Thank you for starting the task" message.

我正在考虑启动一个新线程来处理任务,但是我相信必须有一个更优雅的解决方案,您只需向浏览器发送正确的标头/指令,然后继续进行处理即可.

I’m considering starting a new thread to handle the task, but I believe there must be a more elegant solution, where you just send the right headers/instructions to the browser and then continue processing.

有什么想法吗?

推荐答案

这会将您的消息发送到浏览器:

This will send your message to the browser:

Response.Flush()

但是,我相信通知客户端传输已完成的责任是由IIS完成的,直到ASP.NET引擎完成请求的一部分并将控制权传递回IIS时,IIS才会完成.最好的选择是启动一个新线程,这不会造成任何问题,因为请求线程几乎会在新线程开始后立即结束...每个请求您仍然只有一个线程.

However, I believe the responsibility of notifying the client that the transmission is complete is done by IIS, which it will not do until the ASP.NET engine finishes it's part of the request and passes control back to IIS. Your best bet is to start a new thread, which should not cause any problems since the request thread will end almost immediately after the new one begins... you still only have one thread per request.

这篇关于指示浏览器在继续处理时不要等待更多内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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