Click here to Skip to main content
15,895,799 members
Articles / Desktop Programming / MFC

Threads and shared resources

Rate me:
Please Sign up or sign in to vote.
2.56/5 (6 votes)
31 Aug 20032 min read 52.7K   1.1K   17  
The objective of this article is to demonstrate the result of common access to a resource by different threads
// Shared_DC.h : main header file for the SHARED_DC application
//

#if !defined(AFX_SHARED_DC_H__B069471B_7CF6_410F_9C52_9411C76B2964__INCLUDED_)
#define AFX_SHARED_DC_H__B069471B_7CF6_410F_9C52_9411C76B2964__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH
#endif


#define Threadsafe true
#define UnThreadsafe false
#include "resource.h"		// main symbols
#include <afxmt.h>

/////////////////////////////////////////////////////////////////////////////
// CShared_DCApp:
// See Shared_DC.cpp for the implementation of this class
//

class CShared_DCApp : public CWinApp
{
public:
	CShared_DCApp();
    CWinThread* m_pThreads[5];
    CDC* m_pSharedDC;
    bool m_DCmode;
	CCriticalSection m_cs;
	// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CShared_DCApp)
	public:
	virtual BOOL InitInstance();
	//}}AFX_VIRTUAL

// Implementation

	//{{AFX_MSG(CShared_DCApp)
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()


};
extern CShared_DCApp theApp;

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_SHARED_DC_H__B069471B_7CF6_410F_9C52_9411C76B2964__INCLUDED_)

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer
Denmark Denmark
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions