Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        5年前关闭。
                                                                                            
                
        
我想创建一个计时器来计时并显示秒,但与此同时,我想执行其他操作。有人可以解释我该怎么做,或者在Visual Studio中可以做到吗?

最佳答案

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

关于c - 如何在C中创建计时器? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27285336/

10-11 22:12
查看更多