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: ...

Get C++ Multithreading Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.