Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 3 - 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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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 / 40
    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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Executing Long-Running Tasks with the Progress Bar in ASP.NET - The long-running process (or task)


    (Page 3 of 5 )

    For the long running process, I could not find a proper example other than providing a loop with a certain amount of delay. The loop is iterated ten times and is delayed for about three seconds on every iteration.  In that way, I made a dummy long-running process, which takes about thirty seconds to complete.

    I don’t think that the long-running process is the main issue here in this article.  The most important issue is to update the thread information using “ProcessingStatus.vb” and to show it visually with “UnderProcess.aspx.”  The following is the code fragment which is used as the long-running task in this article:

    'This method is executed by the processing thread.
    Private Sub doProcess()
     
    'do some long task processing here
      ProcessingStatus.add(RequestId, 0)
        'start with percentage 0
     
    Dim i As Integer
     
    For i = 1 To 10
       
    Thread.Sleep(New TimeSpan(0, 0, 0, 3,0))
         'wait for 3 seconds for every iteration
        ProcessingStatus.update(RequestId, i * 10)
         'update percentage with a value between 0 to 100
      
    Next
     
    ProcessingStatus.update(RequestId, -1)
       'after completing the task succesfully, just update status as -1
    End Sub

    I provided commenting everywhere necessary. The first important issue to understand is that the above sub-program (doProcess) gets executed in a separate thread (as explained in the previous section).  Let us consider the first statement within the above fragment:

    ProcessingStatus.add(RequestId, 0)

    The above statement adds new GUID with percentage completion as zero using “ProcessingStatus.vb.”  This gets executed when a new process is about to start (taking into the scenario of multiple users).

    Thread.Sleep(New TimeSpan(0, 0, 0, 3, 0))

    The above statement creates a delay of three seconds.

    ProcessingStatus.update(RequestId, i * 10)

    The above statement updates the status of GUID added above with a certain percentage value for every iteration of the loop.

    ProcessingStatus.update(RequestId, -1)

    The above statement updates the percentage of same GUID added above with a percentage value of “-1”.  I made a rule in my application that, if the percentage value is “-1”, the process has been successfully completed (this would in turn make “UnderProcess.vb” understand easily that the process has been completed).

    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...
     

    VISUAL BASIC.NET ARTICLES

    - Movement and Player Statistics in a VB.NET T...
    - Creating and Drawing a Game Map in VB.NET
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway