Updating two progress bars using two threads
For multitasking, you need more than one thread running simultaneously. The focus of this recipe is on understanding how two tasks can be performed asynchronously via two threads, that is, how CPU time is allocated to these two threads and how switching is done between them.
This recipe will help you understand how two threads run independently without interfering with each other. We will be making use of two progress bars in this recipe. One progress bar will represent progress in downloading a file, and the other progress bar will represent progress in scanning for viruses on the current drive. Both progress bars will progress independently of each other through two different threads.
How to do it...
Let's learn how two progress bars are managed by two threads. To understand how CPU time is allocated to each running thread to execute two tasks simultaneously, perform the following steps:
- Let's create an application based on the
Dialog without Buttons...