Click here to Skip to main content
15,902,114 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Starting a Subclass Pin
palbano14-Jul-04 11:17
palbano14-Jul-04 11:17 
GeneralRe: Starting a Subclass Pin
Zero_G14-Jul-04 11:28
Zero_G14-Jul-04 11:28 
GeneralRe: Starting a Subclass Pin
palbano14-Jul-04 11:44
palbano14-Jul-04 11:44 
GeneralSSL + Server - Client Pin
surfman1914-Jul-04 10:34
surfman1914-Jul-04 10:34 
GeneralIsPVoice Pin
H Talley14-Jul-04 10:10
H Talley14-Jul-04 10:10 
GeneralWriting Files Directly to a CD-RW Pin
nde_plume14-Jul-04 10:09
nde_plume14-Jul-04 10:09 
GeneralRe: Writing Files Directly to a CD-RW Pin
HumanOsc14-Jul-04 10:42
HumanOsc14-Jul-04 10:42 
Generalusing CEvent problem Pin
Hesham Amin14-Jul-04 9:51
Hesham Amin14-Jul-04 9:51 
Hi I use this code to test CEvent MFC Class :
(Win32 Console App with MFC support)
// TryEvent.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "TryEvent.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#include <afxmt.h>
/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;
CEvent ev(TRUE,TRUE);

using namespace std;

UINT Start(void* data)
{
	int n=ev.Lock();
	//WaitForSingleObject(ev.m_hObject,INFINITE); //Also tried this but not good
	
	cout <<"Inside Thread\n";
	return 0;
}


int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;
	CEvent ev;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		cerr << _T("Fatal Error: MFC initialization failed") << endl;
		nRetCode = 1;
	}
	else
	{
		// TODO: code your application's behavior here.
		CString strHello;
		strHello.LoadString(IDS_HELLO);
		cout << (LPCTSTR)strHello << endl;
	}
	
	int n=ev.ResetEvent();
	AfxBeginThread(Start,NULL,0);
	cout <<"Before Thread\n";
	Sleep(5000);
	n=ev.SetEvent();
	Sleep(5000);
	cout <<"The End\n";

	return nRetCode;
}

the expected result should be that the "Before Thread" apperas then the "Inside Thread" after 5 seconds..
but it seems that the secondry thread does not wait for the SetEvent
I read this sample :http://simplesamples.info/MFC/Events.php[^]but no good Frown | :(
any help ?
GeneralRe: using CEvent problem Pin
David Crow14-Jul-04 10:22
David Crow14-Jul-04 10:22 
GeneralRe: using CEvent problem Pin
palbano14-Jul-04 11:13
palbano14-Jul-04 11:13 
GeneralRe: using CEvent problem Pin
Hesham Amin14-Jul-04 19:29
Hesham Amin14-Jul-04 19:29 
Generalintercept file input and outputs Pin
Scozturk14-Jul-04 7:58
professionalScozturk14-Jul-04 7:58 
GeneralRe: intercept file input and outputs Pin
David Crow14-Jul-04 9:19
David Crow14-Jul-04 9:19 
GeneralSybian OS Series 60 SDK Pin
sicruise14-Jul-04 6:57
sicruise14-Jul-04 6:57 
GeneralRe: Sybian OS Series 60 SDK Pin
Antony M Kancidrowski15-Jul-04 1:56
Antony M Kancidrowski15-Jul-04 1:56 
GeneralQuestion with std::ifstream Pin
garfieldlee9914-Jul-04 6:35
garfieldlee9914-Jul-04 6:35 
QuestionUse C# dll inside C++? Pin
So and So14-Jul-04 6:12
So and So14-Jul-04 6:12 
AnswerRe: Use C# dll inside C++? Pin
mav.northwind14-Jul-04 9:37
mav.northwind14-Jul-04 9:37 
GeneralRe: Use C# dll inside C++? Pin
So and So14-Jul-04 12:56
So and So14-Jul-04 12:56 
GeneralRe: Use C# dll inside C++? Pin
mav.northwind14-Jul-04 20:12
mav.northwind14-Jul-04 20:12 
GeneralCDialog & Free Memory Pin
NMiceli14-Jul-04 6:07
NMiceli14-Jul-04 6:07 
GeneralRe: CDialog &amp; Free Memory Pin
David Crow14-Jul-04 9:25
David Crow14-Jul-04 9:25 
QuestionWeb Detector??? Pin
Daron Tan14-Jul-04 6:00
Daron Tan14-Jul-04 6:00 
AnswerRe: Web Detector??? Pin
Scozturk14-Jul-04 8:01
professionalScozturk14-Jul-04 8:01 
QuestionConstructive Solid Geometry C++ classes&#8230; ? Pin
anderslundsgard14-Jul-04 5:30
anderslundsgard14-Jul-04 5:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.