Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Concurrency Runtime in Visual C++ 2010

, 11 Nov 2010
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
#endif



// 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

BEGIN_MESSAGE_MAP(CCRMFCAppApp, CWinApp)
	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()


// CCRMFCAppApp construction

CCRMFCAppApp::CCRMFCAppApp()
{
	// 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.
	INITCOMMONCONTROLSEX InitCtrls;
	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;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

#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);	

#endif
	
	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.

License

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

Share

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

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