Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Executing Long-Running Tasks with the Prog...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Executing Long-Running Tasks with the Progress Bar in ASP.NET
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 53
    2005-08-31

    Table of Contents:
  • Executing Long-Running Tasks with the Progress Bar in ASP.NET
  • The structure of the VS.NET solution
  • The long-running process (or task)
  • Showing the progress
  • What is “ProcessingStatus.vb” in detail?

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Executing Long-Running Tasks with the Progress Bar in ASP.NET - Showing the progress


    (Page 4 of 5 )

    This is the actual section which shows the progress to the user in the form of a progress bar.  The “UnderProcess.vb” takes care of this process. 

    The “UnderProcess.vb” mainly contains two labels, “lblMsg” and “lblProgressBar.”  “lblMsg” shows what percentage it has completed in the form of words.  “lblProgressBar” was designed with a blue background color.  This gets expanded (indirectly; the width of the label) based on the percentage value for every auto-refresh of the same page.  The following is the entire code present in the “page load“ event of “UnderProcess.vb.”

    ' Get the request id
    Dim requestId As New Guid(Request.
    QueryString("RequestId").ToString())
    'Check the processing thread status collection
    If (ProcessingStatus.Contains(requestId))Then
     
    'StatusValue contains either a value between 0 to 100 or -1 (-1 shows that the task is finished)
     
    Dim StatusValue As Integer =
    CType(ProcessingStatus.getValue(requestId), Integer)
     
    If StatusValue = -1 Then
      'processing task succesfully finished
       
    ProcessingStatus.remove(requestId)
        'remove the status
       
    Response.Redirect("finshed.aspx")
        'go to result page
     
    EndIf

      'if not finished, display the status
     
    ' Remove the status from the collection
     
    Me.lblMsg.Text = "Wait for a moment.." & StatusValue & "% Completed.."
     
    Me.lblProgressBar.Width = Unit.Pixel(2 * StatusValue)
      '200 pixels for 100%
    EndIf

    ' The processing  has not yet finished
    ' Add a refresh header, to refresh the page in 2 seconds.
    Response.AddHeader("Refresh", "2")

    I commented the above program very clearly to help you understand every statement in detail. I hope you can understand it.

    The “Finshed.aspx” has nothing other than a simple label with a message “Completed Successfully.”  No processing is done at “Finished.aspx”.

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Thanx a lot for this. I've always thought that multithreading is only useful for...
       · Hello,The article is just only to give you an idea of implementing the progress...
       · You can still further discuss, if you have doubts. I am here to answer you.
       · Any thoughts on how this might be applied to file uploads? It seems like the...
       · You might use the concept of "streaming the binary content" for your requirement. I...
       · Hi, Thanks for sharing this code. My question is how is the 'requestId' got removed...
       · Good catch! Even I never thought of it. Right now, I could not think of very good...
       · I copied and run the code in my machine and getting "ProcessingStatus not defined"...
       · Have you had any further thoughts on "how is the 'requestId' got removed in case...
       · Hi thereI'm trying to use your example but the doprocess is not starting and...
       · Hi,I'm also using your technique to show progress, however i'm concerned about...
       · Hello Jags,I also have a similar implementation of the threading in my...
       · Very thanks for your article. I solved a long time task issue running asp.net over...
     

    VISUAL BASIC.NET ARTICLES

    - User-defined Functions using Visual Basic Ap...
    - Understanding Object Binding in VBA
    - Mastering the Message Box
    - Testing a Windows Forms Application
    - Using Visual Basic.NET Features to Code a Wi...
    - Correcting Code in a Windows Forms Applicati...
    - Write Readable Code and Comments for Windows...
    - How to Code and Test a Windows Forms Applica...
    - Adding Features to a Windows Forms Applicati...
    - How to Design a Windows Forms Application
    - LINQ to XML Programming Using Visual Basic.N...
    - Understanding Delegates using Visual Basic.N...
    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek