Click here to Skip to main content
15,909,373 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: switch on multi threading in visual studio using boost libraries [modified] Pin
minkowski10-Jul-09 1:41
minkowski10-Jul-09 1:41 
GeneralRe: switch on multi threading in visual studio using boost libraries Pin
Stuart Dootson10-Jul-09 2:04
professionalStuart Dootson10-Jul-09 2:04 
GeneralRe: switch on multi threading in visual studio using boost libraries Pin
minkowski10-Jul-09 2:57
minkowski10-Jul-09 2:57 
GeneralRe: switch on multi threading in visual studio using boost libraries Pin
Stuart Dootson10-Jul-09 4:46
professionalStuart Dootson10-Jul-09 4:46 
GeneralRe: switch on multi threading in visual studio using boost libraries Pin
minkowski10-Jul-09 4:53
minkowski10-Jul-09 4:53 
GeneralRe: switch on multi threading in visual studio using boost libraries Pin
Stuart Dootson10-Jul-09 5:06
professionalStuart Dootson10-Jul-09 5:06 
Questionlinking a CiSliderX with a spin edit buddy pair (working with discrete values) [modified] Pin
swati10109-Jul-09 20:28
swati10109-Jul-09 20:28 
QuestionHelp with threads Pin
FISH7869-Jul-09 16:54
FISH7869-Jul-09 16:54 
I am trying to follow this:
Creating Threads using the CreateThread() API[^]">

However I am having an issue, My thread is still running even though the main process id done.
What I am trying to achive is a loop to create threads and wait for all the threads to finish the process before I run the same process again.
My Issue is I get a message to say my loop is done, however the thread is still running. Could someone please shed some light.
DWORD WINAPI Thread_1(LPVOID lpParam)
{
		int a =0;
		char Temp[256];
		THREADDATA*	pData	= (THREADDATA*) lpParam;
		UINT		nEid	= pData->nEditId;
		CThreadDemoDlg*	pDlg	= pData->pObjDlg;
		for (a = 0;a<20;a++)
		{
		_itoa_s(a,Temp,sizeof(Temp),10);
		pDlg->SetDlgItemText(nEid,Temp);
		ProcessMessages();
		}
		return 0;
}

DWORD WINAPI Thread_2(LPVOID lpParam)
{
		int a =0;
		char Temp[256];
		THREADDATA*	pData	= (THREADDATA*) lpParam;
		UINT		nEid	= pData->nEditId;
		CThreadDemoDlg*	pDlg	= pData->pObjDlg;
		for (a = 0;a<20;a++)
		{
		_itoa_s(a+1,Temp,sizeof(Temp),10);
		pDlg->SetDlgItemText(nEid,Temp);
                  Sleep(1000);
		ProcessMessages();
		}
		return 0;
}



TD1->pObjDlg = this;
TD2->pObjDlg = this;
TD1->nEditId = IDC_STATIC1;
TD2->nEditId = IDC_STATIC2;

HANDLE hThread_1;
HANDLE hThread_2;

HANDLE Array_Thread[2];


for (x=0 x<10;x++)
{
        hThread_1 = CreateThread(NULL,0,Thread_1,TD1,0,NULL);
        if (hThread_1 == NULL)
	     ExitProcess(-1);
        hThread_2 = CreateThread(NULL,0,Thread_2,TD2,0,NULL);
        if (hThread_2 == NULL)
	     ExitProcess(-1);
        ProcessMessages();
        x++;
        _itoa_s(f,Temp,sizeof(Temp),10);
        SetDlgItemText(IDC_Main,Temp);
        Array_Thread[0]= hThread_1;
        Array_Thread[1]= hThread_2;
        
        WaitForMultipleObjects(2,Array_Thread,TRUE,INFINITE);
        CloseHandle(hThread_1);
        CloseHandle(hThread_2);
        //The aim is to wait for the unctions to finish before any of the threads start again
}
MessageBox("Done","Information",MB_OKCANCEL);

I get the messagebox, however the The second thread is still running.
QuestionRe: Help with threads Pin
«_Superman_»9-Jul-09 19:44
professional«_Superman_»9-Jul-09 19:44 
AnswerRe: Help with threads Pin
FISH78610-Jul-09 1:51
FISH78610-Jul-09 1:51 
AnswerRe: Help with threads Pin
Roger Stoltz9-Jul-09 22:23
Roger Stoltz9-Jul-09 22:23 
GeneralRe: Help with threads Pin
FISH78610-Jul-09 0:34
FISH78610-Jul-09 0:34 
AnswerRe: Help with threads Pin
Rajesh R Subramanian9-Jul-09 22:52
professionalRajesh R Subramanian9-Jul-09 22:52 
GeneralRe: Help with threads Pin
Roger Stoltz10-Jul-09 1:03
Roger Stoltz10-Jul-09 1:03 
GeneralRe: Help with threads Pin
Rajesh R Subramanian10-Jul-09 1:08
professionalRajesh R Subramanian10-Jul-09 1:08 
Questionmfc tab problem Pin
DevelopmentNoob9-Jul-09 16:15
DevelopmentNoob9-Jul-09 16:15 
AnswerRe: mfc tab problem Pin
«_Superman_»9-Jul-09 19:47
professional«_Superman_»9-Jul-09 19:47 
GeneralRe: mfc tab problem Pin
DevelopmentNoob16-Jul-09 21:18
DevelopmentNoob16-Jul-09 21:18 
QuestionIs it safe to cast from LPBYTE to LPSTR to LPBYTE ? Pin
Mike the Red9-Jul-09 13:47
Mike the Red9-Jul-09 13:47 
AnswerRe: Is it safe to cast from LPBYTE to LPSTR to LPBYTE ? Pin
Stuart Dootson9-Jul-09 14:19
professionalStuart Dootson9-Jul-09 14:19 
JokeThanks, Stuart! -nt- Pin
Mike the Red9-Jul-09 15:43
Mike the Red9-Jul-09 15:43 
QuestionFormat CEdit for Phone Number Pin
DanYELL9-Jul-09 12:04
DanYELL9-Jul-09 12:04 
AnswerRe: Format CEdit for Phone Number Pin
David Crow9-Jul-09 16:11
David Crow9-Jul-09 16:11 
GeneralRe: Format CEdit for Phone Number Pin
kilt9-Jul-09 23:25
kilt9-Jul-09 23:25 
GeneralRe: Format CEdit for Phone Number Pin
DanYELL10-Jul-09 1:46
DanYELL10-Jul-09 1:46 

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.