Executing Long-Running Tasks with the Progress Bar in ASP.NET - What is “ProcessingStatus.vb” in detail?
(Page 5 of 5 )
You must have observed that I wrote plenty of statements starting with “ProcessingStatus” in the above fragments of code (of the previous sections). Actually, it is my own class having only “shared” members. I developed this class to hold all GUIDs and their percentage values respectively. Of course, you could also develop a very good concrete class rather than a class with all “shared” members. But, this class has already passed my requirements (apart from thread safety issues). Let’s see the class:
Imports System.Collections
Public Class ProcessingStatus
Private Shared Status As New Hashtable
Public Shared Function getValue(ByVal itemId As Guid) As Object
Return Status(itemId)
End Function
Public Shared Sub add(ByVal ItemId As Guid, ByVal oStatus As Object)
'make sure that oStatus contains only the values 0 through 100 or -1
Status(ItemId) = oStatus
End Sub
Public Shared Sub update(ByVal ItemId As Guid, ByVal oStatus As Object)
'make sure that oStatus contains only the values 0 through 100 or -1
Status(ItemId) = oStatus
End Sub
Public Shared Sub remove(ByVal ItemId As Guid)
Status.Remove(ItemId)
End Sub
Public Shared Function Contains(ByVal ItemId As Guid) As Boolean
Return Status.Contains(ItemId)
End Function
End Class
In the above program, I maintained a single “HashTable” throughout the class to hold all GUIDs and their respective percentage values. All of the methods in the above class provide a better interface to the “HashTable,” so that you can do all CRUD operations with “HashTable” efficiently.
Summary
The sample downloadable solution is entirely developed using Visual Studio.NET 2003 Enterprise Artchitect on Windows Server 2003 Standard Edition. But, I am confident that it would work with other versions of Windows (which support .NET 1.1) versions as well.
You can further enhance the solution to show the status (or progress) in a small separate window as well to make it convenient to the user. But this article focussed only on the core issue of handling tasks rather than UI. I hope this article will help you to solve your needs.
Any comments, suggestions, bugs, errors, feedback etc. are highly appreciated at jag_chat@yahoo.com.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |