Click here to Skip to main content
12,895,911 members (51,937 online)
Click here to Skip to main content


160 bookmarked
Posted 12 May 2010

Concurrency Runtime in Visual C++ 2010

, 11 Nov 2010 CPOL
Learn about parallel algorithms, parallel containers, tasks, task groups, agents library, task scheduler etc in VC10
// CR MFC App.cpp : Defines the class behaviors for the application.

#include "stdafx.h"
#include "CR MFC App.h"
#include "CR MFC AppDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW

// Uncomment following line to disable message-box in Debug build
 #define _DEBUG_RUNNABLE 1

/* MFC Application for illustrating the Concurrency RunTime				*/
/* Update History of this Code (project):								*/
/* Sept 2, 2010	First version released,									*/
/*				parallel_for, parallel_for_each, parallel_invoke		*/
/*				and combinable class demonstrated.						*/

/*  Warnings Disabled:

	4244 : parallel_for has some bug when LONGLONG parameter is passed.
           In short: it deduces number of CPUs needed to put for execution 
  		   and says "possible loss of data" - Can there be ULONGLONG' CPUS? 




// CCRMFCAppApp construction

	// TODO: add construction code here,
	// Place all significant initialization in InitInstance

// The one and only CCRMFCAppApp object

CCRMFCAppApp theApp;

// CCRMFCAppApp initialization

BOOL CCRMFCAppApp::InitInstance()
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;


#if defined(_DEBUG) && !defined(_DEBUG_RUNNABLE)

	AfxMessageBox( _T("You are running the Debug build of this application.\n")
		_T("For small tasks, the concurrency/parallel tasks would perform slower than serial execution.\n")
		_T("\n#define _DEBUG_RUNNABLE 1   to disable this message in Debug run."), MB_ICONEXCLAMATION);	

	CCRMFCAppDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	else if (nResponse == IDCANCEL)
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ajay Vijayvargiya
Software Developer (Senior)
India India
Started programming with GwBasic back in 1996 (Those lovely days!). Found the hidden talent!

Touched COBOL and Quick Basic for a while.

Finally learned C and C++ entirely on my own, and fell in love with C++, still in love! Began with Turbo C 2.0/3.0, then to VC6 for 4 years! Finally on VC2008/2010.

I enjoy programming, mostly the system programming, but the UI is always on top of MFC! Quite experienced on other environments and platforms, but I prefer Visual C++. Zeal to learn, and to share!

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170424.1 | Last Updated 12 Nov 2010
Article Copyright 2010 by Ajay Vijayvargiya
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid