Progress ? What Progress ?
In most applications there are scenarios where you want to start some long running background tasks (reading/writing data, executing business logic etc.) and keep your users updated about the progress.
In web applications this usually gets complicated and often leads to a mix of code that is executed on the client and on the server.
I recently had such a scenario in an ASP.NET application that I am maintaining for a customer and while dealing with UpdateProgress, UpdatePanel, etc. I was wondering how it would look like in Wisej.
With Wisej it is actually very straight forward. Let me illustrate that with a small demo app.
Please note that this sample is best run with WebSocket support. Otherwise the window only updates when the user interacts with the window.
Consider you have a long running background task that is divided into several steps. Each of those steps consist of a number of sub-steps to be completed.
In my sample I simplified the logic a bit so that each step consists of a fixed number of sub-steps and each sub-step takes the same time to execute. Of course this can be easily changed to match the real life parameters.
Once you hit the „Start background task“, you will immediately see the progress in a progress bar (for the Sub-Steps) and in a progress circle (for the Steps, i.e. overall progress).
You can cancel the process at any time by hitting the Cancel button.
In case you want to have some modal execution where the user has to wait for the background task to be finished, before he can continue using the application, you can check the checkbox „block execution“. Please note that you will still see all the progress updates !
The designer code
First we have designed the window by using the Visual Studio designer only:
You can see the progress bar, progress circle, labels Step/Sub-Step and the text boxes for setting up the parameters. The hidden cancel button is also visible here and is shown when the background task is started (only if block execution is false).
The source code
All the code for this sample is executed on the server. There is no client side code involved it´s plain C#. Let’s look at the details.
Code for Start background task click:
Code for DoExecution ()
Code for Cancel button Click
With Wisej, being a real time web application framework, you can push updates using WebSockets from the server code to the client at any time during execution.
This makes it much easier to keep your users informed about the current status of any background tasks.