Fais un test avec confirmation...
CWinThread *th;
DWORD ec;
bool StopThreadRequired;
bool ThreadStopped;
UINT scanIp(void* pDialog)
{
StopThreadRequired = ThreadStopped = false
//Longue boucle while(!StopThreadRequired ){}
ThreadStopped = true
return 1;
}
void CScanDlg: nStart()
{
th = AfxBeginThread(scanIp,this);
}
void CScanDlg: nStop()
{
GetExitCodeThread(th->m_hThread,&ec);
StopThreadRequired = true;
while(ThreadStopped)
{
Sleep(100);
}
//AfxEndThread(ec); //CA PLANTE !
}
Sinon, en POSIX il y a moyen de faire des points de sychronisation, c'est en fait l'ideal dans ton cas, le AfxEndThread() est un point de synchro avec la fin de la methode IpScan()...