Book Image

C++ Multithreading Cookbook

By : Miloš Ljumović
Book Image

C++ Multithreading Cookbook

By: Miloš Ljumović

Overview of this book

<p>Creating multithreaded applications is a present-day approach towards programming. With the power of C++, you can easily create various types of applications and perform parallelism and optimizations in your existing work. This book is a practical, powerful, and easy-to-understand guide to C++ multithreading. You will learn how to benefit from the multithreaded approach and enhance your development skills to build better applications. This book will not only help you avoid problems when creating parallel code, but also help you to understand synchronization techniques. The end goal of the book will be to impart various multithreading concepts that will enable you to do parallel computing and concurrent programming quickly and efficiently.</p>
Table of Contents (17 chapters)
C++ Multithreading Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Explaining the Message Passing Interface


In order to explain message passing in detail we'll discuss the button click. Like any other control, it belongs to some top-level window, whose procedure is called when a button click event is raised as a response to the mouse button press.

The following example will demonstrate the basic usage of message handling, responsible for the mouse move and button-click.

Getting ready

Make sure that Visual Studio is up and running.

How to do it...

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

  1. Create a new empty C++ Win32 project application named basic_MPI.

  2. Open Solution Explorer and right-click on Source file. Add the new source file named basic_MPI. Open basic_MPI.cpp and add the following code to it:

    #include <windows.h>
    #include <windowsx.h>
    #include <tchar.h>
    
    #include <commctrl.h>
    
    #pragma comment ( lib, "comctl32.lib" )
    #pragma comment ( linker, "\"/manifestdependency:type='win32' \
    name='Microsoft...