-
July 29th, 2018, 11:55 PM
#1
Thread
hello all,
i have created a gui in vc++ with 2 buttons,one to start thread and other to stop thread.my code is
void CMtDlg::OnButton1()
{
// TODO: Add your control notification handler code here
//m_ctrlStatus.SetWindowText(L"Starting...");
THREADSTRUCT *_param = new THREADSTRUCT;
_param->_this = this;
m_ctrlStatus.Format("Starting...%d",i);
UpdateData(FALSE);
mainthread=AfxBeginThread(MyThreadProc, _param); // <<== START THE THREAD
m_op.Format("out");
UpdateData(FALSE);
//void CMtDlg::OnButton2();
}
void CMtDlg::OnButton2()
{
THREADSTRUCT *_param = new THREADSTRUCT;
_param->_this = this;
// TODO: Add your control notification handler code here
//stopNow = TRUE;
//KillTimer(1234);
//m_ctrlStatus.Format("Stopped %d",i);
//UpdateData(FALSE);
mainthread = AfxEndThread(MyThreadProc, 0);
m_op.Format("hi");
UpdateData(FALSE);
}
but i am not sure about stopping the thread which i have started.how do i overcome this..plz help
-
July 30th, 2018, 01:48 AM
#2
Re: Thread
Well, if you are going to work with threads in MFC - start learning to do it the right way! This great Joe Newcomer's essay:
Using Worker Threads will help you.
Victor Nijegorodov
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|