正在加载图片...
9.2 1.使用全局变量实现线程间通信 在上一节程序的基础上,进行以下操作: (1)在“线程”菜单中添加菜单项:“终止线程”, ID THREAD STOP。 (2)在 Thread Test view.cpp文件中添加一个全局变量 thread Controller,用来控 制线程是否继续。添加方法是在 Thread Test view. cpp的最上面,在 endif 下面添加下面的语句: volatile int thread Controller (3)在视类中为“停止线程”添加消息处理函数 On ThreadStop() void CThread TestView: On ThreadStopo thread Controller=01. 使用全局变量实现线程间通信 在上一节程序的基础上,进行以下操作: (1)在“线程”菜单中添加菜单项:“终止线程” ,ID_THREAD_STOP。 (2)在ThreadTestView.cpp文件中添加一个全局变量threadController,用来控 制线程是否继续。添加方法是在ThreadTestView.cpp的最上面,在endif 下面添加下面的语句: volatile int threadController; (3)在视类中为“停止线程”添加消息处理函数OnThreadStop()。 9.2 void CThreadTestView::OnThreadStop() { threadController = 0; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有