Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
How to implement a multi-threaded Progress dialog
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.
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.