Click here to Skip to main content
15,920,468 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: error C2259: : cannot instantiate abstract class Pin
Taka Muraoka16-Jul-06 3:28
Taka Muraoka16-Jul-06 3:28 
GeneralRe: error C2259: : cannot instantiate abstract class Pin
RockyJames16-Jul-06 3:42
RockyJames16-Jul-06 3:42 
GeneralRe: error C2259: : cannot instantiate abstract class Pin
Taka Muraoka16-Jul-06 4:02
Taka Muraoka16-Jul-06 4:02 
GeneralRe: error C2259: : cannot instantiate abstract class Pin
Mike Dimmick16-Jul-06 7:23
Mike Dimmick16-Jul-06 7:23 
Questionsteps for connection with server? Pin
With_problem16-Jul-06 1:15
With_problem16-Jul-06 1:15 
AnswerRe: steps for connection with server? Pin
Mike Dimmick16-Jul-06 6:48
Mike Dimmick16-Jul-06 6:48 
AnswerRe: steps for connection with server? Pin
ThatsAlok16-Jul-06 22:40
ThatsAlok16-Jul-06 22:40 
AnswerRe: steps for connection with server? Pin
David Crow17-Jul-06 3:27
David Crow17-Jul-06 3:27 
QuestionProblem with 2D Graph ActiveX Control [modified] Pin
Semion_N16-Jul-06 0:43
Semion_N16-Jul-06 0:43 
AnswerRe: Problem with 2D Graph ActiveX Control Pin
Semion_N16-Jul-06 4:12
Semion_N16-Jul-06 4:12 
AnswerRe: Problem with 2D Graph ActiveX Control Pin
Semion_N16-Jul-06 8:18
Semion_N16-Jul-06 8:18 
QuestionSaving a BITMAP on disc Pin
snir_ya15-Jul-06 23:49
snir_ya15-Jul-06 23:49 
AnswerRe: Saving a BITMAP on disc Pin
Hamid_RT16-Jul-06 0:28
Hamid_RT16-Jul-06 0:28 
AnswerRe: Saving a BITMAP on disc Pin
bob1697216-Jul-06 6:47
bob1697216-Jul-06 6:47 
AnswerRe: Saving a BITMAP on disc Pin
ThatsAlok16-Jul-06 22:39
ThatsAlok16-Jul-06 22:39 
AnswerRe: Saving a BITMAP on disc Pin
David Crow17-Jul-06 3:34
David Crow17-Jul-06 3:34 
QuestionThread help!!! Pin
User 34160315-Jul-06 23:33
User 34160315-Jul-06 23:33 
Hi everybody!

I'm making a routing algo simulator using MFC and GDI+.
I have created three function that are the three steps the algo does: ElectCluster(); FindMember(); StartSteadyState();.

Now the StartSteadyState() creates a thread for each node of the network that has been elected Cluster head (p->ch).
<br />
void CSimDlg::StartSteadyState(void)<br />
[...].br />
	for (int i=0; i<m_vecNodes.size(); i++)<br />
	{<br />
		NODE* p = m_vecNodes[i];<br />
		<br />
		if(p->ch)<br />
		{<br />
			ThreadParam* pParam = new ThreadParam;<br />
			pParam->m_pDialog = this;<br />
			pParam->m_nNodeIndex = i;<br />
			_beginthread(StaticTx, 0, (void*)pParam);<br />
			counter++;<br />
		}<br />
	}<br />
[...].


and:
void CSimDlg::StaticTx(void * param)<br />
{<br />
	ThreadParam* pParam = (ThreadParam*)param;<br />
	pParam->m_pDialog->Tx(pParam->m_nNodeIndex);<br />
	delete pParam;<br />
}<br />
<br />
void CSimDlg::Tx(int nNodeIndex)<br />
{<br />
	[simulate transmission]<br />
	[graphic: draw nodes and color lines of the link used]<br />
}


Now my problem is that I would like to make different rounds:
<br />
void CSimDlg::OnBnClickedStart()<br />
{<br />
		for(int i=0; i < NumberOfRounds; i++)<br />
		{<br />
			ElectCluster();<br />
			FindMember();<br />
			StartSteadyState();<br />
		}<br />
}


This obviosly doesn't work because "for" doesn't wait for all the thread created by StartSteadyState();

I have tried to solve using:
<br />
hThread = (HANDLE)_beginthread(StaticTx, 0, (void*)pParam);<br />
WaitForSingleObject(hThread,INFINITE);<br />

It seems to work but doesn't shows the graphic. I have tried to put a MessageBox before WaitForSingleObject and for as long as I don't press the ok button I see that the links and nodes are coloring. pressing ok the graphic part stops.

What am I doing wrong?
Do you have any advices or suggestion?

modified 11-Mar-21 21:01pm.

AnswerRe: Thread help!!! Pin
DrSerge15-Jul-06 23:48
DrSerge15-Jul-06 23:48 
GeneralRe: Thread help!!! Pin
User 34160316-Jul-06 0:17
User 34160316-Jul-06 0:17 
AnswerRe: Thread help!!! Pin
Justin Tay16-Jul-06 3:12
Justin Tay16-Jul-06 3:12 
GeneralRe: Thread help!!! Pin
User 34160316-Jul-06 4:25
User 34160316-Jul-06 4:25 
GeneralRe: Thread help!!! Pin
Justin Tay16-Jul-06 6:56
Justin Tay16-Jul-06 6:56 
QuestionDestroy ToolTip Ctrl Pin
sir_moreno15-Jul-06 23:07
sir_moreno15-Jul-06 23:07 
GeneralHelp for all Pin
hybride15-Jul-06 21:41
hybride15-Jul-06 21:41 
GeneralRe: Help for all Pin
ThatsAlok16-Jul-06 21:14
ThatsAlok16-Jul-06 21:14 

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.