新手请教:有关终止工作线程的问题 急!急! 各位大虾: 在VC中终止工作线程一般都采用主线程和工作线程通信的方式,我现在想在线程外面也就是主线程中直接终止线程(就象linux下的kill),而不需要和线程内部通信,该怎么办? 请各位帮忙,谢谢了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 BOOL TerminateProcess( HANDLE hProcess, // handle to the process UINT uExitCode // exit code for the process); TerminateThread()这个函数终止线程的手段非常强硬,不到万不得以不要用他!不过楼主的意思我想就是强制结束线程吧! 在一个线程中终止一个线程:BOOL TerminateProcess( HANDLE hProcess, // handle to the process UINT uExitCode // exit code for the process);结束本线程: ExitProcess 在一个线程中终止另一个线程:BOOL TerminateProcess( HANDLE hProcess, // handle to the process UINT uExitCode // exit code for the process);结束本线程: ExitProcess /******************************************************************************** 退出线程 ********************************************************************************/DWORD m_ThreadID; //线程IDHANDLE m_hThread; //线程句柄int ExitThread(){ if (TerminateThread(m_hThread, 4)) { DWORD dwExitCode =0; while(TRUE) { GetExitCodeThread(m_hThread, &dwExitCode); if (dwExitCode != STILL_ACTIVE) break; Sleep(10); } CloseHandle(m_hThread); } return 0;} BOOL TerminateProcess( HANDLE hProcess, // handle to the process UINT uExitCode // exit code for the process); TerminateProcess()的权利太大了,一般进程结束,系统会通知该进程的所有开启DLL结束,但使用TerminateProcess()系统就不会做这个工作,你就可以想到后果了。 CListCtrl CheckBox编辑 关于用ATL写自动化应用程序的问题??? 各位前辈请帮忙! vc怎样把一天24小时分为3段 为什么英文版的VC下面,程序不能正确显示汉字 请问如何解决vc中的连接问题 也许你也在迷惑!都来看看吧! vc自己生成的空dll编译后为什么就有1m多? 在MFC 中用StretchBlt 将图片贴到对话框中,有什么方法能使这张图清除呢 找书!!!!!!!! 当vc6.0与msdn 2003无法关联,应该怎么办? 新手求救,请多关照!!!
HANDLE hProcess, // handle to the process
UINT uExitCode // exit code for the process
);
不过楼主的意思我想就是强制结束线程吧!
BOOL TerminateProcess(
HANDLE hProcess, // handle to the process
UINT uExitCode // exit code for the process
);
结束本线程:
ExitProcess
BOOL TerminateProcess(
HANDLE hProcess, // handle to the process
UINT uExitCode // exit code for the process
);
结束本线程:
ExitProcess
* 退出线程 *
*******************************************************************************/
DWORD m_ThreadID; //线程ID
HANDLE m_hThread; //线程句柄
int ExitThread()
{
if (TerminateThread(m_hThread, 4))
{
DWORD dwExitCode =0;
while(TRUE)
{
GetExitCodeThread(m_hThread, &dwExitCode);
if (dwExitCode != STILL_ACTIVE)
break;
Sleep(10);
}
CloseHandle(m_hThread);
} return 0;
}
HANDLE hProcess, // handle to the process
UINT uExitCode // exit code for the process
);