blah blah blah is here! blah blah » Close

up0down
link

I recently received a question asking how to deliver part of the web page to the client while allowing the server to finish its processing before delivering the rest.
The technique is relatively straightforward, but I thought I'd post a thread about it because until I went searching, I didn't know how to do it either.
The following code loops from 1 to 50 and sends each line of output to the client as it completes.
... Page_Load(){
for(int i = 0; i < 50; i++){
Response.Write("
currently at: " + i.ToString());
Response.Flush(); //send all buffer output to the client
System.Threading.Thread.Sleep(2000);
}
}

last answered 2 years ago

1 answers

up0down
link

Great idea jerry, I'm thinking of starting a code snippet section and this would be a great snippet.

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback