O'Reilly logo

C++ Multithreading Cookbook by Milos Ljumovic

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the BackgroundWorker class

As we said before, EAP is a very good mechanism, which enables a programmer to create multithreaded applications easily and with much less coding. The BackgroundWorker object is a general-purpose implementation of the EAP, and has many good features, such as the handy cancelation model, the ability to safely update another thread's UI controls, the reporting progress feature, exception forwarding, raising completion event, and more. We'll now implement our factorial example using the BackgroundWorker class that resides in the System::ComponentModel namespace.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

Now, let's create our program and explain its structure. Perform the following steps: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required