计算从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();

备注

相关链接

 

最新文章

  1. VR 相关专业词汇
  2. ios推送
  3. android标题栏(titlebar)显示进度条
  4. 20141104--SQL连接查询,联合查询
  5. Socket层上的协议
  6. HTTP协议&SOCKET协议
  7. 取消putty右键粘贴功能
  8. 【CJOJ2498】【DP合集】最长上升子序列 LIS
  9. 学习使人快乐8--Maven
  10. 【CTSC2018】暴力写挂(边分治,虚树)
  11. Mysql 数据库增删改查
  12. hdu-2063-过山车(匈牙利算法)
  13. android studio 下载 sdk 失败
  14. 开源项目MultiChoiceAdapter详解(一)——概要介绍
  15. UVa 10954 全部相加(Huffman编码)
  16. line tension
  17. http 协议 c++代码 获取网页
  18. 基础概念 之 Spark on Yarn
  19. javascript005_Object
  20. 第二百三十六节,Bootstrap辅组类和响应式工具

热门文章

  1. 保护眼睛,开启浏览器的夜间模式 顺便学下!important的作用
  2. POJ 1160 Post Office
  3. C# chart,有关如何在鼠标移动到Series上时显示节点及数据 (有待继续更新)
  4. [转] AE之分级颜色专题图渲染
  5. C# 如何以参数的形式调用.exe程序
  6. 无人机DLG生产作业流程
  7. [转] error LNK2026: 模块对于 SAFESEH 映像是不安全的
  8. (原创)LAMP教程6-使用SecureCRTPortable工具远程连接centos
  9. Codeforces Round #361 (Div. 2) 套题
  10. linux常用命令之--文件打包与压缩命令