如何慢慢地向网页添加内容? [英] How to slowly add content to a web page?

查看:79
本文介绍了如何慢慢地向网页添加内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击我的aspx页面上的一个按钮时,它会启动一堆

个线程,这些线程会执行可能需要几秒钟的事情。

相反在呈现

响应之前等待所有线程完成,有没有办法显示每个线程的当前状态?


理想情况下,状态是显示在文字控件或文本框中。它可能会说线程已启动。并且在完成时完成线程,

并且没有特别的顺序。


这对于页面渲染速度非常慢。


如何实施?


感谢您的帮助。

解决方案

我甚至无法想象为什么在处理请求时你需要在服务器上打开几个

个线程?一个

例外:发送电子邮件,但通常不需要时间




简单的答案是否定的。但您可以尝试使用服务器计时器将用户

重定向到具有

控件的不同文本属性的同一页面上。从来没有这样做过因为

没有必要:)

-----原始消息-----
当用户点击我的aspx页面上的按钮时,
会启动一堆线程,这些线程可以执行每个可能需要几美元b $ b秒的事情。而不是等待所有线程在$ b $之前完成b渲染响应,有没有办法显示
每个线程的当前状态?
理想情况下,状态将显示在文字控件或
a文本框中。可能会说可能是线程开始。并且在
完成线程已完成,并且没有特别的顺序。

这对于
页面的渲染速度非常慢。
怎么能这可以实施吗?

感谢您的帮助。



没有。客户端正在查看的是处理结果已经在服务器上发生并完成了
。您可以这样想想,客户正在查看的网页是已经完成并转移到其他内容的某些

流程的结果。


现在,如果你想进入ActiveX控件或Java Applet,那将是一个不同的故事,因为这些是自包含的可执行程序

从网页启动但是(一旦启动)可以独立运行

it。

" Bruce W.1" <峰; br *** @ noDirectEmail.com>在消息中写道

news:3F *************** @ noDirectEmail.com ...

当用户点击一个时我的aspx页面上的按钮它启动了一堆
线程,这些线程会执行可能需要几秒钟的事情。
而不是在呈现
响应之前等待所有线程完成,而不是有没有办法显示每个线程的当前状态?

理想情况下,状态将显示在文字控件或文本框中。它会说可能是线程开始。并且在完成时线程已完成,
并且没有特别的顺序。

这对于页面的渲染速度非常慢。

怎么能这可以实现吗?

感谢您的帮助。



一种解决方案是将响应对象作为参数传递给每个线程。

线程可以在它启动时和任何时候自由写入。

当你需要在线程处理后更新屏幕时你会打电话给

Response对象上的静态刷新方法。在我的脑海中,我不知道你不会确定是否会遇到同步问题,因为它取决于你操纵的响应对象的哪一部分 - 一些方法是线程

安全其他人不是。


或者,您可以使用会话对象将数据从线程

传输到你的主线程。设置你的主页面以不断刷新自己。

每次刷新时,你检查一个会话变量标志,以确定是否有需要在屏幕上显示的数据
主页。如果有,你需要从会话变量中检索数据并将其显示在刷新

过程中并在响应对象上调用flush。会话数据变量

将由各个线程设置。您需要同步访问权限。

这个想法大致相当于启动画面。这应该足够了

让你入门。


-

问候,

Alvin布鲁尼

有DotNet吗?在此处获取
http://home.networkip.net /dotnet/tidbits/default.htm

< an ******* @ discussion.microsoft.com>在留言中写道

news:00 **************************** @ phx.gbl ... < blockquote class =post_quotes>我甚至无法想象为什么在处理请求时你需要在服务器上打开几个
线程?一个例外:发送电子邮件,但通常不用花时间


简单的答案是否定的。但您可以尝试使用服务器计时器将用户
重定向到具有
控件的不同文本属性的同一页面上。从来没有这样做过因为
没有必要:)

-----原始消息-----
当用户点击我的aspx页面上的一个按钮


启动了一堆

线程,这些线程可以执行一些可能需要几个


秒的线程。

而不是等待所有线程在


呈现

响应之前完成,有没有办法显示当前状态


每个线程?


理想情况下,状态将显示在文字控件或


文本框中。它

会说可能是线程开始。并且


完成线程已完成,

并且没有特别的顺序。

这对于非常缓慢的呈现非常有用


页面。


如何实现?

感谢您的帮助。



When a user clicks on a button on my aspx page it launches a bunch of
threads which go and do things which might take a few seconds each.
Rather than waiting for all threads to complete before rendering the
response, is there a way to show the current status of each thread?

Ideally the status would be shown in a literal control or a textbox. It
would say maybe "thread started" and on completion "thread completed",
and in no particular order.

This would be analagous to a very slow rendering of the page.

How can this be implemented?

Thanks for your help.

解决方案

I can''t even imagine why would you need to open several
threads on a server while it processing the request? One
exception: sending email, but usually it takes no time
anyway.

The simple answer is no. But you can try to redirect user
on the same page with different text attribute of your
control using server timer. Never done this before because
there was no need :)

-----Original Message-----
When a user clicks on a button on my aspx page it launches a bunch ofthreads which go and do things which might take a few seconds each.Rather than waiting for all threads to complete before rendering theresponse, is there a way to show the current status of each thread?
Ideally the status would be shown in a literal control or a textbox. Itwould say maybe "thread started" and on completion "thread completed",and in no particular order.

This would be analagous to a very slow rendering of the page.
How can this be implemented?

Thanks for your help.
.



No. What the client is looking at is the RESULT of the processing that has
already taken place and completed on the server. You can think of it this
way, the web page that the client is looking at is the results from some
process that has already completed and moved on to other things.

Now, if you wanted to get into ActiveX controls or Java Applets, that would
be a different story because those are self-contained executable programs
that are launched from a web page but (once launched) can run independant of
it.
"Bruce W.1" <br***@noDirectEmail.com> wrote in message
news:3F***************@noDirectEmail.com...

When a user clicks on a button on my aspx page it launches a bunch of
threads which go and do things which might take a few seconds each.
Rather than waiting for all threads to complete before rendering the
response, is there a way to show the current status of each thread?

Ideally the status would be shown in a literal control or a textbox. It
would say maybe "thread started" and on completion "thread completed",
and in no particular order.

This would be analagous to a very slow rendering of the page.

How can this be implemented?

Thanks for your help.



One solution is to pass the response object as a parameter to each thread.
The thread can freely write to it whenever it starts and whenver it is done.
When you need the screen to update after thread processing you would call
the static flush method on the Response object. Off the top of my head, i''m
not sure if you will run into synchronization issues since it depends on
what part of the response object you manipulate - some methods are thread
safe others are not.

Alternatively, you can use the session object to transfer data from threads
to your main thread. Set up your main page to continuously refresh itself.
With each refresh, you check a session variable flag to determine if there
is data needed to be displayed on screen in the main page. If there is, you
retrieve data from a session variable and display it in the refresh
procedure and call flush on the response object. The session data variables
will be set by the individual threads. You will need to synchronize access.
The idea is roughly equivalent to a splash screen. That should be enough to
get you started.

--
Regards,
Alvin Bruney
Got DotNet? Get it here
http://home.networkip.net/dotnet/tidbits/default.htm
<an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...

I can''t even imagine why would you need to open several
threads on a server while it processing the request? One
exception: sending email, but usually it takes no time
anyway.

The simple answer is no. But you can try to redirect user
on the same page with different text attribute of your
control using server timer. Never done this before because
there was no need :)

-----Original Message-----
When a user clicks on a button on my aspx page it


launches a bunch of

threads which go and do things which might take a few


seconds each.

Rather than waiting for all threads to complete before


rendering the

response, is there a way to show the current status of


each thread?


Ideally the status would be shown in a literal control or


a textbox. It

would say maybe "thread started" and on


completion "thread completed",

and in no particular order.

This would be analagous to a very slow rendering of the


page.


How can this be implemented?

Thanks for your help.
.



这篇关于如何慢慢地向网页添加内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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