Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a thread HELP!

Status
Not open for further replies.

jl3574

Programmer
Joined
Jun 5, 2003
Messages
76
Location
CA
i'm trying to create a thread in visual c++
i created a dialog project using Crecordview
in one of the buttons i'm trying to create and start a thread

i declare my thread globally my code is :

UINT thread( LPVOID nParam );//declare thread
.
.
.
void CRecordView::OnButtonFunction()
{
AfxBeginThread(thread,this);
}


UINT thread( LPVOID nParam )//definition
{
//some function here
return 0;
}

when i reach the onbuttonfunction it reads the line
AfxBeginThread(thread,this) but it never calls the thread?
i think i might have to create a CWindThread to run this but i'm not sure how? pls help!
 
>> but it never calls the thread?

And you know that because??

-pete
 
i enter some code in the thread to put data in the database and it never enters that thread
and i tested otu the code else where and it runs.

i entered breakpoints and enter debug mode and it never enters that breakpoint
 
In a file "maindlg.cpp"
Code:
UINT thread(LPVOID lpParam){
	TRACE("thread: %d\r\n", ::GetCurrentThreadId());
	return 0;
}

then in the BOOL CMainDlg::OnInitDialog() (same file "maindlg.cpp")

Code:
	AfxBeginThread( thread, this);

The trace message is displayed successfully in the output window.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top