ASP.NET异步页的用户界面 [英] ASP.NET asynchronous page user interface

查看:83
本文介绍了ASP.NET异步页的用户界面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用我的Web应用程序,在ASP.NET 4.0 ASP.NET 2.0的异步页功能。
我已经通过附加元件preRenderCompleteAsync 方法设置开始和结束任务操作,
我有一个标签,上面写着操作开始关于页面加载,然后开始任务开始。

为什么我无法看到这个标签,直到异步操作完成?
实际上,这是作为一个同步操作一样好。

不应该,而异步任务是同步进行的页面加载和显示标签?


解决方案

  

为什么我无法看到这个标签,直到异步操作完成?


由于您正在创建仅在服务器端的异步操作。要充分理解这个概念,你需要了解 ASP.Net页面生命周期在简单的话,对用户的响应不会返回,直到页面已经被完全处理

所以,你可能想知道...什么好处呢?那么实际的好处是的扩展的。 ASP.Net提供一个线程的固定号码以用来处理请求时,已经使用线程的最大数量,传入请求将被放置在一个队列可能阻塞的Web应用程序。

当你(在你的案件等)调用异步方法,你的释放由ASP.Net 使用的线程,然后可以用来处理传入的请求。当你的长耗时的操作完成后,页面的光线实例在一个新的线程重新创建,以处理您的 end方法

如果你想显示一个操作的进度,需要调用使用AJAX的服务器的方法


  

不应该,而异步任务是同步进行的页面加载和显示标签?


都能跟得上

有关详细信息:

如何显示异步结果哪一个是先在asp.netweb应用?

I'm using the Asynchronous page feature of ASP.NET 2.0 in my web application that is on ASP.NET 4.0. I have set the begin and end task operations through AddOnPreRenderCompleteAsync method, and I have a label that says "operation started" on page load and then the begin task starts.

Why am I not able to see this label until the asynchronous operation is completed? In effect, it's as good as a synchronous operation.

Shouldn't the page load and display the label while the asynchronous task is being carried out simultaneously?

解决方案

Why am I not able to see this label until the asynchronous operation is completed?

Because you are creating an Async operation on the server side only. To fully understand the concept you need to understand the ASP.Net page life-cycle. In simple words, the response to the user won't return UNTIL THE PAGE HAS BEEN FULLY PROCESSED

So you might be wondering... What's the benefit then? Well the actual benefit is scalability. ASP.Net provides a fixed number of threads to be used to handle requests, when the max number of threads have been used, incoming requests will be placed in a queue blocking potentially the web application.

When you call an async method (like in your case), you are releasing the thread used by ASP.Net which then can be used to process incoming requests. When your long-time-consuming operation finishes, a light instance of the page is re-created in a new thread to process your end method

If you want to show the progress of an operation, you need to call the server-method using AJAX

Shouldn't the page load and display the label while the asynchronous task is being carried out simultaneously?

Nope

For more information:

How to display the Asynchronous results which one is first in asp.netweb application?

这篇关于ASP.NET异步页的用户界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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