By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,354 Members | 907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,354 IT Pros & Developers. It's quick & easy.

How to slowly add content to a web page?

P: n/a
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.
Nov 18 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
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.
.

Nov 18 '05 #2

P: n/a
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.

Nov 18 '05 #3

P: n/a
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.
.

Nov 18 '05 #4

P: n/a
"Bruce W.1" <br***@noDirectEmail.com> wrote in
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?


Bruce,

http://www.fawcette.com/vsm/2002_11/...tures/chester/

You should be able to adapt the article to meet your needs by having
a master ("status") thread that spawns and manages the child
("worker") threads.

Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 18 '05 #5

P: n/a
"Chris R. Timmons" wrote:

Bruce,

http://www.fawcette.com/vsm/2002_11/...tures/chester/

You should be able to adapt the article to meet your needs by having
a master ("status") thread that spawns and manages the child
("worker") threads.

Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

================================================== ===========

If I understand this right, the results aspx page is just slowly
displaying an XML document, transformed nicely into html.

Similar behavior comes from the display of a large text file, i.e. it
displays as it loads.

So then the million dollar question is, how can this behavior be put in
to an aspx web form? Or can this behavior be put in to an aspx web
form?
Nov 18 '05 #6

P: n/a
"Bruce W.1" <br***@noDirectEmail.com> wrote in
news:3F***************@noDirectEmail.com:
If I understand this right, the results aspx page is just slowly
displaying an XML document, transformed nicely into html.

Similar behavior comes from the display of a large text file,
i.e. it displays as it loads.

So then the million dollar question is, how can this behavior be
put in to an aspx web form? Or can this behavior be put in to
an aspx web form?


Bruce,

The output can be in any format you want. Instead of using an
XmlDocument, you could dynamically create ASP.NET web controls, or
insert text or HTML into a literal control.

I've ported the example code to C#, and modified it to use plain text
and a literal control instead of XML for output. If you'd like, I
can zip up the code and e-mail it to you (I'll need your e-mail
address of course). Or I could post it here if anyone else is
interested.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 18 '05 #7

P: n/a
Shouldn't have a problem implementing the suggestions left by others
here if you're also sure to:

- Set the page's BufferOutput property to True
- Called .Flush() after each line you want to output to the client as
the operation progresses.
- Made sure you don't have any open table tags between output. Some
browsers won't render partial tables, whether the output is flushed or not.

Also, remember that if you want to redirect or something after the
operation has completed, you'll need to do it in client script since the
HTTP headers have already been written out. Just a gotcha I've run into.

-----
Aaron Lewis
GuildPortal.com Development
www.guildportal.com

Nov 18 '05 #8

P: n/a
Aaron Lewis wrote:

Shouldn't have a problem implementing the suggestions left by others
here if you're also sure to:

- Set the page's BufferOutput property to True
- Called .Flush() after each line you want to output to the client as
the operation progresses.
- Made sure you don't have any open table tags between output. Some
browsers won't render partial tables, whether the output is flushed or not.

Also, remember that if you want to redirect or something after the
operation has completed, you'll need to do it in client script since the
HTTP headers have already been written out. Just a gotcha I've run into.

-----
Aaron Lewis
GuildPortal.com Development
www.guildportal.com


================================================== ==========

That sounds like really good advice and I must try it sometime. But I'm
sorry to say that I have shifted gears and turned it in to a No-Touch
Deployment (NTD) winforms program, and it works great. ASP.NET is not
so great for real-time information.

Of course it only runs on .NET. That's okay for now.

I wish Microsoft would let NTD programs run in an IE browser window.
Nov 18 '05 #9

P: n/a
Yeah I've done a WinForms version of my web-based application, and
working with Windows Forms is so much nicer than with web apps...
Partially because of the "neatness" factor of managing synchronization,
updating, and offline manipulation of data coming from a series of
remote web services, and using threads to do it. I'm a newbie to a lot
of parts of the .NET framework, so hitting new areas is great fun!

You know what would be REALLY cool, though? If the future version with
the Windows Forms or Avalon or whatever it's called, with the UI mark-up
called XAML (right?), could be portable between windows and web apps.
I mean, a treeview is a treeview right? If I have a Windows Forms app
with a TreeView and a ListView in it, and the output of the form is
XAML, why couldn't IIS or the framework itself see that and render
either a Windows Form or a Web Form, depending upon the context of the
client? THAT would be extremely cool. :)

By the way, about NTD in the browser, have you tried using the OBJECT
tag and referencing the DLL + class name for one of your Windows Forms
in HTML? I hear it works the way old-style OCX would..

-----
Aaron Lewis
GuildPortal.com Development
www.guildportal.com

Bruce W.1 wrote:
That sounds like really good advice and I must try it sometime. But I'm
sorry to say that I have shifted gears and turned it in to a No-Touch
Deployment (NTD) winforms program, and it works great. ASP.NET is not
so great for real-time information.

Of course it only runs on .NET. That's okay for now.

I wish Microsoft would let NTD programs run in an IE browser window.


--

Nov 18 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.