void CMFCThirdMutilThreadDlg::OnBnClickedButtonAdd()
{
CString strText;
long shuMu=1;
DWORD t1 = GetTickCount();//程式段開始前取得系統運行時間(ms)
m_lst_demo.SetRedraw(false);
while (shuMu <= 5000) {
strText.Format(_T("%ld"), shuMu);
m_lst_demo.AddString(strText);//strText
m_lst_demo.SetCurSel(m_lst_demo.GetCount() - 1);
shuMu++;
}
m_lst_demo.SetRedraw(true);
CString temp_value = _T(""); //temp_value用來處理int值
temp_value.Format(_T("%d"), GetTickCount()- t1);//固定格式
AfxMessageBox(temp_value+" 毫秒");
}
以上代碼可以執行,但是效果不好。聽說在OnBnClickedButtonAdd里不宜寫回圈,要用執行緒實作。但我不知道怎么寫,誰幫忙寫一下,最后附上代碼,謝謝!
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/66426.html
標籤:VC.NET
