I have a process intensive asp.net page that takes up to two minutes to finish processing. It's a backoffice page that connects to different web services / API's, does some stuff and returns either success or error + error message, that gets displayed in order on a datagrid.
I know I can't do the process faster, because the web services / API's are 3rd party. But I wan't to "smooth" the end user's performance.
Is there anyway to get the datagrid "updated", so the end user see's the results of each connection to the API's? Instead of waiting until the whole page process, and then get the results. Is some kind of flush? or dump? I tryed response.flush() but it doesn't do anithing I can see.
Thanks
HoraShadowDo not use any of ASP.NET's built in controls, instead, manually write a table using Response.Write and Response.Flush.
Another thing you have to do is specify the column widths on the table in pixels for ALL columns, otherwise the end user's browser will wait for the whole table before it shows it. If you specify all the widths manually up front, most browsers will write the table as it receives it.
Thanks for your answer Lord_Rat!.
I tryed your suggestion with a test page, but I couldn't get it to work. After 6 seconds it display the entire page. Instead of flushing segments.
I used the debugger of vs2003 and IE6.1.
This is de code I used to try this out is:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim counter
Response.Write("<table border=1>")
Response.Flush()
For counter = 0 To 5
wait(counter)
Next
Response.Write("</table>")
Response.Flush()
End Sub
Private Sub wait(ByVal cycle As Integer)
sytem.threading.thread.sleep(2000)
Response.Write("<tr><td width=500>" & cycle.ToString & " | " & now & "</td></tr>")
Response.Flush()
End Sub
What I'm missing for this test to work?
Thanks
HoraShadow
Response.Write("<table border=1>")
Change to :
Response.Write("<table border=""1"" width=""500"">")
Response.Write("<colgroup")
Response.Write("<col width=""500"" />")
Response.Write("</colgroup>")
You don't have to specify a width on the TD elements themselves.
Thanks again for replying!
I still can't get it to work. I must be doing something wrong, but I don't realize where, or what. :blush:
The test code right now looks like this:
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim counter
Response.Write("<table border=""1"" width=""500"">")
Response.Write("<colgroup>")
Response.Write("<col width=""500"" />")
Response.Write("</colgroup>")
Response.Flush()
For counter = 1 To 5
System.Threading.Thread.Sleep(2000)
Response.Write("<tr><td>" & counter & "</td></tr>")
Response.Flush()
Next
Response.Write("</table>")
End Sub
While the page process, If I right click and select view source, I can see the tr and td forming up. But it still doesn't display as it gets received. The code IS received, row by row, but not displayed. It gets displayed as soon as the page finishes rendering and gets dumped to the browser.
The html code looks weird too. It looks like this:
<table border="1" width="500"><colgroup><col width="500" /></colgroup><tr><td>1</td></tr><tr><td>2</td></tr><tr><td>3</td></tr><tr><td>4</td></tr><tr><td>5</td></tr></table>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
</form>
</body>
</HTML>
The table gets dumped before anithing else. Maybe that's what's giving me issues?
Thanks
HoraShadow
Resolved! Thanks!.
The error I was having, was that the browser doesn't display the table flushed untill it receives the /table. The browser displays complete tables, not just pratial tables.
Thanks a bunch Lord_Rat!
Saturday, March 31, 2012
smoothing the end users page performance
Labels:
asp,
backoffice,
connects,
intensive,
net,
page,
performance,
process,
processing,
smoothing,
users,
web
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment