我想创建一个计算秒数并显示它们的计时器,但同时我想做其他操作。有人可以解释我如何做到这一点,或者这是否可行(在Visual Studio中)?
答案 0 :(得分:1)
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