MFC 多线程编程简单实例
清泛原创
简单的例子:
#include "stdafx.h"
#include <windows.h>
DWORD WINAPI ThreadProc(LPVOID lpParam)
{
printf("ThreadProc\n");
return -1;
}
int _tmain(int argc, _TCHAR* argv[])
{
DWORD dwThreadId;
HANDLE hThread = CreateThread(
NULL,
0,
ThreadProc,
NULL, // 需要传递给回调函数的参数(数据),可为NULL
0,
&dwThreadId);
printf("ThreadID:%d\n", dwThreadId);
// 等待线程运行结束
if (WAIT_OBJECT_0 == WaitForSingleObject(hThread, INFINITE))
printf("Thread end.\n");
return 0;
}
上一篇:为何用了MoveWindow函数后窗口不显示
下一篇:mfc对话框字体不正常?