×
Namespaces

Variants
Actions

How to implement a multi-threaded Progress dialog

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code ExampleArticle
Created: mudhalvan (28 Jun 2007)
Last edited: hamishwillee (26 Jul 2012)

The general usage of implementing a progress dialog is to notify the user that a background process is going on. So the progress bar is updated as per the state of the process, which happens in background. If the usecase is as simple as to update the progress bar with just a timeline( say 0.5 or 1 sec ), we can very well use the RTimer API which is provided by the active object framework.

But if the usecase is to update a progress bar upon the results of a Synchronous process( say User::After()API ), then they cannot be implemented as it is. If the result of a synchronous function is directly used for moving the progress bar in the progress dialog, then the entire UI thread will be blocked until the progress dialog gets dismissed.

Here comes the benefit of using a multi-threaded progress dialog, where the main UI thread will be having the progress dialog, which gets updated by another thread, in which the synchronous process is executed. The advantage of doing like this is to ensure that the main UI thread does'nt get blocked and while the progress bar moves in the dialog, the main thread can continue to do other processing, if required. In summary, we are making a synchronous process to behave asynchronously such that the main UI thread is prevented from getting blocked.

Here is the link for the sample application( with source code ) which demonstrates the multi-threaded progress dialog using threads and active object framework.

File:WikiProgressDialog.zip

In the above sample application, User::After() synchronous function behaves like a asynchronous function, such that the progress dialog will not block the main UI thread.

This page was last modified on 26 July 2012, at 02:59.
61 page views in the last 30 days.
×