ПАРАЛЛЕЛЬНОЕ ПРОГРАММИРОВАНИЕ
161
static char THIS_FILE[] = __FILE__;
#endif
CRITICAL_SECTION Sect1; //Declaration of critical section;
HANDLE hMutex; //Declaration of mutex handle
int GlobalCounter=100; //Global Variable
int mode=0; //Mode:0-Normal, 1-CritSect, 2-Mutex
/////////////////////////////////////////////////////////////////////////////
// CCritDlg dialog
CCritDlg::CCritDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCritDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCritDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CCritDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCritDlg)
DDX_Control(pDX, IDC_LIST4, m_List4);
DDX_Control(pDX, IDC_LIST3, m_List3);
DDX_Control(pDX, IDC_LIST2, m_List2);
DDX_Control(pDX, IDC_LIST1, m_List1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCritDlg, CDialog)
//{{AFX_MSG_MAP(CCritDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCritDlg message handlers
BOOL CCritDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
// TODO: Add extra initialization here
InitializeCriticalSection(&Sect1); ////////////////////
hMutex=CreateMutex(NULL,false,"MySuperMutex"); // Initialisation //
return TRUE;
}
void CCritDlg::OnPaint()
{
if (IsIconic())