Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
定时器的使用 我有一个C++应用程序,我想每1分钟调用一个函数。我从一个朋友那里得到了这个代码(感谢他)_C++_Windows_Api_Timer - Fatal编程技术网

定时器的使用 我有一个C++应用程序,我想每1分钟调用一个函数。我从一个朋友那里得到了这个代码(感谢他)

定时器的使用 我有一个C++应用程序,我想每1分钟调用一个函数。我从一个朋友那里得到了这个代码(感谢他),c++,windows,api,timer,C++,Windows,Api,Timer,但是我不能在一段时间后执行其余的程序。因此,我正在寻找一种解决方案,以便每分钟执行所有代码和函数。您使用的是windows计时器消息。应用程序在GetMessage停止,直到WM\u QUIT被发布到线程队列 最简单的方法是使用一个线程并在那里调用f,然后睡眠一分钟 今天关于计时器的第三个问题! void CALLBACK f(HWND hwnd, UINT uMsg, UINT timerId, DWORD dwTime) { printf("Hello"); } int main()

但是我不能在一段时间后执行其余的程序。因此,我正在寻找一种解决方案,以便每分钟执行所有代码和函数。

您使用的是windows计时器消息。应用程序在
GetMessage
停止,直到
WM\u QUIT
被发布到线程队列


最简单的方法是使用一个线程并在那里调用f,然后睡眠一分钟

今天关于计时器的第三个问题!
void CALLBACK f(HWND hwnd, UINT uMsg, UINT timerId, DWORD dwTime)
{
  printf("Hello");
}

int main() 
{
  MSG msg;

  SetTimer(NULL, 0, 1000*60,(TIMERPROC) &f);
  while(GetMessage(&msg, NULL, 0, 0)) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
//Here I have the rest of my appliation
  return 0;
}