我想用 mfc 编写多线程就是没有成功.请求大家给点示例,最好有注释.
线程之间如何通信.
线程之间如何通信.
解决方案 »
- 动态创建按钮和响应 很多按钮100个或更多 怎么实现? 在线等~~~
- 一个关于listcontrol控件的问题
- 简单问题,如何彻底卸载dll(解决后马上结帖)
- Unicode转化的问题?
- 关于Release和Debug的问题
- 如何将一个CString的变量转存到一个unsigned short 的数组中去?高手请解答,谢谢(100)
- 为什么我的一个.lib文件在程序连接执行的时候,提示告诉我打不开该文件!
- ZwCreateFile 导致蓝屏,请教是为什么?
- 拉伸位图怎么做?
- MFC 遍历文件名写入数组
- 救命呀~~~!连接错误~~~!!!
- WM_PAINT里面有画图的条件判断,InvalidateRect如果调用WM_PAINT就不是局部刷新。如果不调用WM_PAINT那么它又是怎么根据判断条件(在哪?
{
DECLARE_DYNCREATE(CMyThread)
public:
//初始化线程标号和对话框指针
CMyThread(int m_ID); // protected constructor used by dynamic creation// Attributes
public:// Operations
public:
int ID; //线程标号
bool IsWork; //线程工作标志
CMySocket m_sAcceptSocket; //接受连接套接字// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyThread)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL// Implementation
public:
virtual ~CMyThread(); // Generated message map functions
//{{AFX_MSG(CMyThread)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG DECLARE_MESSAGE_MAP()
}; m_Thread[i] = new CMyThread(i);
if (!m_Thread[i]->CreateThread(CREATE_SUSPENDED))
{
for(int j = 0; j < i; j++)
if(m_Thread[j] != NULL)
{
m_Thread[i]->ExitInstance();
m_Thread[j] = NULL;
}
delete m_Thread[j];
m_Thread[i] = NULL;
AfxMessageBox("线程建立错误!",MB_OK|MB_ICONSTOP);
return;
}
比如有一个全局变量 Busy =true,那么
while(Busy)
{
MessageBee(0);
}//如果假设是 Thread_2;
进程3 Thread_3 把 Busy = false;并告知
if(! Busy)
{
Busy =false;
MessageBox(" 歇会再响吧 ");
}