Board index » Web Programming » Using thread to partially load a page

Using thread to partially load a page

Web Programming411
I have an aspx page that can take a minute or so to load because it loads

images from a database. I want to open a window and show a "Please Wait"

message page at the start and close it when the page is ready to load with

Response.Write. I have opened a thread to do it but it doesn't work. Any

suggestions?



Here is the relevant part of my code:



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

public class Images : System.Web.UI.Page

{

public static void NewThread()

{

Images wb = new Images();

wb.WaitBox();

}





public void WaitBox()

{

string waitString="" ;

waitString="<script

language=\"javascript\">\n\twaitWindow=window.open(\"plswait.htm\",

\"WaitWindow\",

\"width=600,height=450,toolbar=no,status=no,menubar=no,resizable=no,scrollbars=no\");\n" +

"\twaitWindow.location=\"plswait.htm\";\n</script>";

Response.Write(waitString);

}



private void Page_Load(object sender, System.EventArgs e)

{

Thread thread = new Thread(new ThreadStart(NewThread));

thread.Start();



//

// Build htmlString here

//

//



thread.Abort();

Response.Write(htmlString);

}

}

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

Thanks,

Evan Hicks


-
 

Re:Using thread to partially load a page

Hi Evan:



Here is an alternate approach to review:

msdn.microsoft.com/msdnmag/issues/03/12/DesignPatterns/">msdn.microsoft.com/msdnmag/issues/03/12/DesignPatterns/



You'll fund that you need more participation from the browser to

implement a "wait" screen or a progress bar, because the browser has

no idea what is happening on the server during a long operation.



--

Scott

www.OdeToCode.com/blogs/scott/">www.OdeToCode.com/blogs/scott/



On Tue, 1 Feb 2005 20:49:06 -0800, "Evan"

<Evan@discussions.microsoft.com>wrote:



Quote
I have an aspx page that can take a minute or so to load because it loads

images from a database. I want to open a window and show a "Please Wait"

message page at the start and close it when the page is ready to load with

Response.Write. I have opened a thread to do it but it doesn't work. Any

suggestions?



Here is the relevant part of my code:



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

public class Images : System.Web.UI.Page

{

public static void NewThread()

{

Images wb = new Images();

wb.WaitBox();

}





public void WaitBox()

{

string waitString="" ;

waitString="<script

language=\"javascript\">\n\twaitWindow=window.open(\"plswait.htm\",

\"WaitWindow\",

\"width=600,height=450,toolbar=no,status=no,menubar=no,resizable=no,scrollbars=no\");\n" +

"\twaitWindow.location=\"plswait.htm\";\n</script>";

Response.Write(waitString);

}



private void Page_Load(object sender, System.EventArgs e)

{

Thread thread = new Thread(new ThreadStart(NewThread));

thread.Start();



//

// Build htmlString here

//

//



thread.Abort();

Response.Write(htmlString);

}

}

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

Thanks,

Evan Hicks







-

Re:Using thread to partially load a page

Have you considered caching the output or the data?

"Evan" <Evan@discussions.microsoft.com>wrote in message

Quote
I have an aspx page that can take a minute or so to load because it loads

images from a database. I want to open a window and show a "Please Wait"

message page at the start and close it when the page is ready to load with

Response.Write. I have opened a thread to do it but it doesn't work. Any

suggestions?



Here is the relevant part of my code:



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

public class Images : System.Web.UI.Page

{

public static void NewThread()

{

Images wb = new Images();

wb.WaitBox();

}





public void WaitBox()

{

string waitString="" ;

waitString="<script

language=\"javascript\">\n\twaitWindow=window.open(\"plswait.htm\",

\"WaitWindow\",



\"width=600,height=450,toolbar=no,status=no,menubar=no,resizable=no,scrollba

rs=no\");\n" +

Quote
"\twaitWindow.location=\"plswait.htm\";\n</script>";

Response.Write(waitString);

}



private void Page_Load(object sender, System.EventArgs e)

{

Thread thread = new Thread(new ThreadStart(NewThread));

thread.Start();



//

// Build htmlString here

//

//



thread.Abort();

Response.Write(htmlString);

}

}

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

Thanks,

Evan Hicks









-