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