C++ AfxBeginThread
2024-08-24 01:58:25
计算从1+2+3...+100000=?
关键点
CWinThread*
AfxBeginThread(
AFX_THREADPROC
pfnThreadProc,
LPVOID
pParam,
int
nPriority
=
THREAD_PRIORITY_NORMAL,
UINT
nStackSize
=
0,
DWORD
dwCreateFlags
=
0,
LPSECURITY_ATTRIBUTES
lpSecurityAttrs
=
NULL
);
UINT MyFunction( LPVOID pParam );
实现过程
class CMfc01Dlg : public CDialog
{
// Construction
public:
CMfc01Dlg(CWnd* pParent = NULL); // standard constructor
CWinThread *m_sumProc;
// Dialog Data
UINT SumPro(LPVOID pParam)
{
CMfc01Dlg *pDlg=(CMfc01Dlg*)pParam;
__int64 nSum=0;
char pszText[128]={0};
for (UINT i=1;i<100000;i++)
{
nSum+=i;
memset(pszText,0,128);
wsprintf(pszText,"累计到%d的结果为%I64d",i,nSum);
pDlg->m_listbox1.AddString(pszText);
}
return 0;
}
void CMfc01Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
m_sumProc=AfxBeginThread(SumPro,this,0,0,0,NULL);
} void CMfc01Dlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
if (SumPro!=NULL)
{
DWORD dwExit=0;
BOOL bRet=GetExitCodeThread(m_sumProc->m_hThread,&dwExit);
if (dwExit==STILL_ACTIVE)
{
m_sumProc->ExitInstance();
delete m_sumProc;
}
}
CDialog::OnClose();
}
|
图
备注
相关链接
最新文章
- VR 相关专业词汇
- ios推送
- android标题栏(titlebar)显示进度条
- 20141104--SQL连接查询,联合查询
- Socket层上的协议
- HTTP协议&SOCKET协议
- 取消putty右键粘贴功能
- 【CJOJ2498】【DP合集】最长上升子序列 LIS
- 学习使人快乐8--Maven
- 【CTSC2018】暴力写挂(边分治,虚树)
- Mysql 数据库增删改查
- hdu-2063-过山车(匈牙利算法)
- android studio 下载 sdk 失败
- 开源项目MultiChoiceAdapter详解(一)——概要介绍
- UVa 10954 全部相加(Huffman编码)
- line tension
- http 协议 c++代码 获取网页
- 基础概念 之 Spark on Yarn
- javascript005_Object
- 第二百三十六节,Bootstrap辅组类和响应式工具
热门文章
- 保护眼睛,开启浏览器的夜间模式 顺便学下!important的作用
- POJ 1160 Post Office
- C# chart,有关如何在鼠标移动到Series上时显示节点及数据 (有待继续更新)
- [转] AE之分级颜色专题图渲染
- C# 如何以参数的形式调用.exe程序
- 无人机DLG生产作业流程
- [转] error LNK2026: 模块对于 SAFESEH 映像是不安全的
- (原创)LAMP教程6-使用SecureCRTPortable工具远程连接centos
- Codeforces Round #361 (Div. 2) 套题
- linux常用命令之--文件打包与压缩命令