Now,i used code :
UINT postThread(LPVOID pParam)
{
CGA_SpikeDlg*p = (CGA_SpikeDlg*)pParam;
p->RunTimer();
return 0;
}
void CGA_SpikeDlg::threadNew()
{
AfxBeginThread(postThread, this);
}
void CGA_SpikeDlg::RunTimer()
{
SetTimer(1, 6000, NULL);
}
void task1(M_args Parameter_, double Mtime, double tempVB, double TimeStep, double m_I, int FlagParameter[], M_args_Bound Parameter_Bound[], int MaxGeneration, float gL, float C, const int POPULATION_SIZE, float crossver, float mutations, stringstream &strResult)
{
solveGPU_cpp(Parameter_, Mtime, tempVB, TimeStep, m_I, FlagParameter, Parameter_Bound, MaxGeneration, gL, C, POPULATION_SIZE, crossver, mutations, strResult);
//cout << "task1 says: " << endl;
}
void CGA_SpikeDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
switch (nIDEvent)
{
case 1: //定时器1处理函数,定时发送数据进行更新
{
CString cstr((strResult.str()).c_str());
//str.Format("%f", duration);
m_result.SetWindowText(cstr);
UpdateData(false);
break;
}
}
CDialogEx::OnTimer(nIDEvent);
}
void CGA_SpikeDlg::OnBnClickedButtonRun()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(true);
threadNew();
thread t1(task1, Parameter_, Mtime, tempVB, TimeStep, m_I, FlagParameter, Parameter_Bound, MaxGeneration, gL, C, POPULATION_SIZE, crossver, mutations, std::ref(strResult));
t1.join();
}
I want to show the value of strResult on my EDIT. I want to see how it change when i run.But when i run,The window displays no response,After a period of time, it shows the final result,That's not what I want.