Search KB Filter article types
Using Progress-Bar without threads in IIS
Categories: Status & Indication, Multi-threading
Tags: Architects, Developers, 2. Intermediate, 3. Advanced, Customization, Optimizing Performance, v6.4 and Later
Revision: 1
Posted: 12/Jan/2009
Updated: 12/Jan/2009
Status: Publish
Types: Code

Following some of the discussions in the forums I've seen that people seem to love to progressbar, but do not always want to use it in the way, that the simple examples show. In these samples the VWG-application starts a new thread (which will be within the scope of the hosting web-server). Having more than just one or two request, this will drive you into a scenario which is not entitled "best practise", when it comes to server-products like IIS.
The web-server should - if possible - be the master over all its threads, which will not be the case, when your web-application starts creating a bunch of threads by itself.

So the task is to extract the long-running task from the web-application not only into another thread, but into another scope - to isolate it from the web-application. A simple way of doing this is having a windows-service on the same or on a remote-server which will do the long-running tasks. The only thing that has to be done is to setup some infrastructure for the communication between the web-application and this service.

In the snippet I do not build a service but a console-application. This console-application acts as a WCF Service-Host and exposes a service which has two methods. The web-application simply calls the service-methods if needed, but does not create any threads.
The attachments is a ZIP-Archive which consists of 2 projects : The VWG-application (using V6.4) and the console-application. You need at least .NET 3.0 to run it (as I make use of WCF).

You should make sure, that your local port 8080 is free, so that the host can listen there. If you want to change the port, you can change that in Host.cs of the Console-Application. Remember to change the service-reference in the vwg-app as well.
To run the whole thing, you will have to start the Service-Host first and then the web-application.

Just some words about how it works.
The web-application has a Form which contains a button, a label, a timer and a progressbar.
When the user clicks on the button, the application will call the WCF-service to start a new job and will start the timer-component. Every time, the timer fires, the application will call another method on the WCF-service to get the status of the job that has been started before.

Remember, that this is just a demo. There is no data-transport (if needed) implemented here, but you can use this as a base for a better scaling architecture.

Kristof

 

Note: Codes are submitted as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Terms of Agreement:
By using this code, you agree to the following terms...

1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3. You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


About the author

Related Articles

Status & Indication  
Title Update Author
This video demonstrates how to use the error provider
Tags: Architects, Developers, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
01/Jan/2009    2009/01/01
This video demonstrates how to use the error provider in Visual WebGui.
Tags: Architects, Developers, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
11/Jan/2007    2007/01/11
Tags: Developers, Data Binding, Events, 1. Beginner, 2. Intermediate, Integration, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
05/Jan/2009    2009/01/05
This application demonstrates how to use the Timer to update a TextBox and a ProgressBar control.
Tags: Developers, Events, 1. Beginner, Pre v6.3, v6.3, v6.4 and Later, 2. Intermediate, 3. Advanced
12/Jan/2009    2009/01/12
This article demonstrates the use of an active Gauge in a Visual WebGui application.
Tags: Developers, 1. Beginner, 2. Intermediate, 3. Advanced, v6.3, v6.4 and Later
12/Jan/2009    2009/01/12
Tags: Architects, Developers, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
04/Dec/2010    2010/12/04