eventthread shut down(MFC 如何在主线程中判断子线程是否运行,运行则关闭子线程)

本文目录
MFC 如何在主线程中判断子线程是否运行,运行则关闭子线程
还没弄好?之前和你说过了,其实就是WaitForSingleObject和CEvent,对于MFC,使用Afx方式创建线程有系列的方法可用,只要你保存了这个指针或句柄。
给你找了一段例程序,这里包含了判断和外部结束的全部方法,你不一定要创建这个类,只要保留CWinThread指针即可。
class CScrCapThread : public CWinThread
{
CEvent m_eventKill;
CEvent m_eventDead;
staticCEvent m_eventAnotherDead;
BOOL IsKilling();
BOOL IsDead();
voidKillThread();
virtual void Delete();
}
CScrCapThread::CScrCapThread()
:m_eventKill(FALSE,TRUE)
,m_eventDead(FALSE,TRUE)
{
m_bAutoDelete=FALSE;
}
BOOLCScrCapThread::IsKilling()
{
return::WaitForSingleObject(m_eventKill,0)==WAIT_OBJECT_0;
}
BOOLCScrCapThread::IsDead()
{
return::WaitForSingleObject(m_eventDead,0)==WAIT_OBJECT_0;
}
void CScrCapThread::Delete()
{
// calling the base here won’t do anything but it is a good habit
CWinThread::Delete();
// acknowledge receipt of kill notification
VERIFY(m_eventDead.SetEvent());
VERIFY(m_eventAnotherDead.SetEvent());
}
void CScrCapThread::KillThread()
{
// Note: this function is called in the context of other threads,
// not the thread itself.
// reset the m_hEventKill which signals the thread to shutdown
VERIFY(m_eventKill.SetEvent());
// allow thread to run at higher priority during kill process
SetThreadPriority(THREAD_PRIORITY_ABOVE_NORMAL);
WaitForSingleObject(m_eventDead, INFINITE);
WaitForSingleObject(m_hThread, INFINITE);
// now delete CWinThread object since no longer necessary
if(m_bAutoDelete)
delete this;
}
mysql 主主同步,服务器重启后需要重新做吗
从你的日志来看,并没有报Error的错误,Note表示正常记录事物日志,说明你的主主是好的。
只要不是意外断电造成数据库意外关闭或暴力关闭数据库,就不会出现主从失效的情况,放心吧。
看主从是否同步,主要通过show slave status\G 查看2两个Yes。
例如:
mysql》 show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.17.2.40
Master_User: photorepl
Master_Port: 4331
Connect_Retry: 60
Master_Log_File: mysql-bin.005502
Read_Master_Log_Pos: 64401238
Relay_Log_File: mysqld-relay-bin.015418
Relay_Log_Pos: 13456757
Relay_Master_Log_File: mysql-bin.005152
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
...
...

更多文章:
docker 运行容器(RunV: 让 Docker 支持虚拟化容器)
2026年3月21日 14:15
电脑出现invalid(电脑PHILIPS出现invalid partition table怎么办)
2025年12月30日 16:15
properties转yml(yml文件常见的几种读取方式)
2025年8月26日 03:30
bootstrap框架过时了吗(为什么前端工程师多不愿意用 Bootstrap 框架)
2025年5月28日 09:30
content的用法和固定搭配(content, contented的区别)
2025年6月9日 22:45
数控加工中心代码大全(数控编程的各系统中的各代码代表的什么意思)
2025年12月26日 14:30
把打乱的字母组成单词,并翻译lwak?英语Using awk to transpoose column to row怎么翻译
2026年7月18日 16:00

















