Click here to Skip to main content
15,912,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: File enumeration performance (GetFirstFile) Pin
Mohammad A Gdeisat23-Sep-06 8:25
Mohammad A Gdeisat23-Sep-06 8:25 
GeneralRe: File enumeration performance (GetFirstFile) Pin
Jörgen Sigvardsson23-Sep-06 8:26
Jörgen Sigvardsson23-Sep-06 8:26 
QuestionProblem with getchar(); Pin
EzraYap23-Sep-06 5:27
EzraYap23-Sep-06 5:27 
AnswerRe: Problem with getchar(); Pin
ThatsAlok23-Sep-06 5:53
ThatsAlok23-Sep-06 5:53 
GeneralRe: Problem with getchar(); Pin
EzraYap23-Sep-06 6:04
EzraYap23-Sep-06 6:04 
GeneralRe: Problem with getchar(); Pin
Jörgen Sigvardsson23-Sep-06 8:14
Jörgen Sigvardsson23-Sep-06 8:14 
GeneralRe: Problem with getchar(); Pin
ThatsAlok23-Sep-06 8:40
ThatsAlok23-Sep-06 8:40 
QuestionWhat wrong with this Code ?? ( multiThread in win32 ) Pin
Yanshof23-Sep-06 5:11
Yanshof23-Sep-06 5:11 
Hi All.

I start to learn multiThread and i wrote some simple program.
I dont know why i crash - i try to look into by using debug and i dont see nothing wrong.

IF someone can tell me what i doing in wrong way .... ?Confused | :confused: Confused | :confused: Confused | :confused:

Thanks for any help.

Here the code :

<br />
...<br />
...<br />
 <br />
using namespace std;<br />
<br />
CRITICAL_SECTION sc;<br />
<br />
void __stdcall func(LPVOID param)<br />
{<br />
	char szBuffer[256];<br />
	{<br />
		EnterCriticalSection(&sc);<br />
		long lVal = *((long*)param);<br />
		<br />
		<br />
		while(lVal > 0)<br />
		{<br />
			sprintf(szBuffer, "lVal is : %ld \n", lVal--);<br />
			printf(szBuffer);<br />
		}<br />
		LeaveCriticalSection(&sc);<br />
	}<br />
}<br />
<br />
<br />
void main(void)<br />
{<br />
	HANDLE thread1,thread2;<br />
<br />
	long lVal = 10;<br />
<br />
	thread1 = CreateThread(NULL,<br />
						   5,<br />
						   (LPTHREAD_START_ROUTINE)func,<br />
						   &lVal,<br />
						   CREATE_SUSPENDED,<br />
						   NULL);<br />
<br />
	SetThreadPriority(thread1, THREAD_PRIORITY_HIGHEST);<br />
<br />
	lVal = 1000;<br />
	<br />
	thread2 = CreateThread(NULL,<br />
						   5,<br />
						  (LPTHREAD_START_ROUTINE)func,<br />
						  &lVal,<br />
						  CREATE_SUSPENDED,<br />
						  NULL);<br />
<br />
	SetThreadPriority(thread2, THREAD_PRIORITY_HIGHEST);<br />
<br />
	ResumeThread(thread2);<br />
	ResumeThread(thread1);<br />
	<br />
	WaitForSingleObject(thread2, INFINITE);<br />
	WaitForSingleObject(thread1, INFINITE);<br />
}<br />

AnswerRe: What wrong with this Code ?? ( multiThread in win32 ) Pin
Mohammad A Gdeisat23-Sep-06 6:04
Mohammad A Gdeisat23-Sep-06 6:04 
GeneralRe: What wrong with this Code ?? ( multiThread in win32 ) Pin
Yanshof23-Sep-06 6:08
Yanshof23-Sep-06 6:08 
AnswerRe: What wrong with this Code ?? ( multiThread in win32 ) Pin
Yanshof23-Sep-06 8:16
Yanshof23-Sep-06 8:16 
AnswerRe: What wrong with this Code ?? ( multiThread in win32 ) Pin
Hamid_RT23-Sep-06 8:33
Hamid_RT23-Sep-06 8:33 
AnswerRe: What wrong with this Code ?? ( multiThread in win32 ) Pin
Eytukan23-Sep-06 8:40
Eytukan23-Sep-06 8:40 
GeneralRe: What wrong with this Code ?? ( multiThread in win32 ) Pin
Yanshof23-Sep-06 8:58
Yanshof23-Sep-06 8:58 
AnswerRe: What wrong with this Code ?? ( multiThread in win32 ) Pin
Eytukan23-Sep-06 9:35
Eytukan23-Sep-06 9:35 
QuestionHow to Unload CListCtrl Pin
georgekjolly23-Sep-06 4:12
georgekjolly23-Sep-06 4:12 
AnswerRe: How to Unload CListCtrl Pin
ThatsAlok23-Sep-06 6:02
ThatsAlok23-Sep-06 6:02 
AnswerRe: How to Unload CListCtrl Pin
Jörgen Sigvardsson23-Sep-06 8:20
Jörgen Sigvardsson23-Sep-06 8:20 
GeneralRe: How to Unload CListCtrl Pin
ThatsAlok23-Sep-06 9:09
ThatsAlok23-Sep-06 9:09 
GeneralRe: How to Unload CListCtrl Pin
Jörgen Sigvardsson23-Sep-06 9:11
Jörgen Sigvardsson23-Sep-06 9:11 
GeneralRe: How to Unload CListCtrl Pin
ThatsAlok4-Oct-06 7:35
ThatsAlok4-Oct-06 7:35 
GeneralRe: How to Unload CListCtrl Pin
Jörgen Sigvardsson4-Oct-06 8:17
Jörgen Sigvardsson4-Oct-06 8:17 
GeneralRe: How to Unload CListCtrl Pin
ThatsAlok4-Oct-06 9:19
ThatsAlok4-Oct-06 9:19 
AnswerRe: How to Unload CListCtrl Pin
Hamid_RT23-Sep-06 8:25
Hamid_RT23-Sep-06 8:25 
AnswerRe: How to Unload CListCtrl Pin
Eytukan23-Sep-06 8:53
Eytukan23-Sep-06 8:53 

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.