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  
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 - 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...
       · 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 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek