如何在C ++控制台应用程序中创建计时器? [英] how to create timer in c++ console application?

查看:83
本文介绍了如何在C ++控制台应用程序中创建计时器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,人们..在控制台中,我们做了不同的事情,例如打印值,但是如果我们想放置计时器来更改值,我们应该怎么做.假设在约翰程序中数组中有5个5个值[] = {1,2,3,4,5)并在调试后弹出数字1,对于数字2大约需要30秒左右..好吧,就是这样,我们应该可以放在我们打印的值之间设置计时器?

hello,people.. in console ,there are different things that we do,like printing the values but what should we do if we want to put the timer for changing the values.suppose in program john has 5 five values in array[]={1,2,3,4,5) and after debugging,number 1 pops up and for number 2 it should take like 30 second or so on..well,just thing is ,there we should be able to put timer between the values we print???

推荐答案

使用CreateWaitableTimer [使用等待的计时器对象 [ ^ ]
Use the CreateWaitableTimer[^] function.
Also take a look at Using Waitable Timer Objects[^]


创建线程并在指定的时间内休眠,然后执行作业


void ThreadProc(void * pdata)
{
//处理任务

///计时器像计时器一样工作.
睡眠(100)
}
Create a thread and Sleep for a specified time and execute the job


void ThreadProc( void *pdata)
{
// Work with a task

/// Timer to work like a timer.
Sleep( 100 )
}


这篇关于如何在C ++控制台应用程序中创建计时器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆