Dim PreviousPageTitle As String = Page.Title
Dim TotalIterations As Integer = 1000
Dim StartTime As DateTime = Now
For CurrentInteration As Integer = 0 To TotalIterations
If CurrentInteration > 0 Then
Dim RemainingIterations As Integer = TotalIterations - CurrentInteration
Dim RemainingProgressPercent As Single = 1 - CurrentInteration / TotalIterations
Dim TimePassed As TimeSpan = Now - StartTime
Dim TimeToEnd As New TimeSpan(TotalIterations * TimePassed.Ticks / CurrentInteration)
Dim TimeRemaining As TimeSpan = TimeToEnd - TimePassed
Threading.Thread.Sleep(18)
Response.Flush()
Response.Write(String.Format("<script>document.title = '{0} {1} {2}'</script>", RemainingIterations, TimeRemaining.ToString("m':'ss"), RemainingProgressPercent.ToString("p1")))
End If
Next CurrentInteration
Page.Title = PreviousPageTitle
Response.Write("<script>document.title = '" & PreviousPageTitle & "'</script>")
Tips and tricks for .NET using ASP and VB code.
Show countdown while generating page
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment