0
我想创建一个计时器,计算秒数并显示它们,但并行地我想执行其他操作。有人可以解释我怎么做,或者如果这是可能的(在Visual Studio中)?如何在C中创建一个定时器?
我想创建一个计时器,计算秒数并显示它们,但并行地我想执行其他操作。有人可以解释我怎么做,或者如果这是可能的(在Visual Studio中)?如何在C中创建一个定时器?
This is one way to handle your desired actions.
in main thread,
-fork a child process. passing
1) a desired time interval
2) a callback function ptr
3) indication of oneShot or repeating timer
into the child process,
in the child process:
-begin loop
-sleep the passed-in-time-interval
-execute the call back function
-if non repeating timer
-then
-exit child process
-endif
-end loop
in main thread, in the call back function:
-get current time
-display the current time to user
-return
in main thread, when ready to exit, kill child thread