Use the SetTimer function of the system, set in a long time, across the time of day, time was 78200 seconds, in today's 22:00 Settings, PM the next day, but the problem is that the timing of the trigger delay time delay (experiment 1 minutes and 15 seconds), why is there this problem? For each master
CodePudding user response:
SetTimer () itself is not accurate ~ only when no other messages to be processed in the message queue, to deal with it,
CodePudding user response:
Check also need not so long, 1 minute, but long running timer, better make threads,
CodePudding user response:
reference 1st floor VisualEleven response: SetTimer () itself is not accurate ~ only when no other messages to be processed in the message queue, to deal with it, The program itself is quite simple, does not involve too much message processing, so you can determine the message processing does not take such a long delay time, is there may be internal mechanism of the problem and lead to longer? CodePudding user response:
refer to the second floor jennyvenus response: need not so long, 1 minute to check again, but long running timer, better make threads, Create another thread, or need to wait for so long time to execute, and direct time no difference, or you have a separate thread to timing? CodePudding user response:
You can use a tick count thread to timing CodePudding user response:
Timer, really takes place are commonly tooltip disappear automatically, such as application to stability, especially the time driven program, itself to run for a long time, must be stable and stable than the timer thread, CodePudding user response:
reference 5 floor VisualEleven reply: can use a tick count thread to timing Specific how to operate? CodePudding user response:
refer to 6th floor jennyvenus response: timer, general really takes place is like a tooltip disappear automatically, the program to be stable, especially time driven program, itself to run for a long time, must be stable and stable than the timer thread, Specific how to operate? CodePudding user response:
refer to the original poster waterbright response: use the SetTimer function of the system, set in a long time, across the time of day, time was 78200 seconds, in today's 22:00 Settings, PM the next day, but the problem is that the timing of the trigger delay time delay (experiment 1 minutes and 15 seconds), why is there this problem? For each master It is not a precision timing, 78200 error 75 you see error rate, it has been very accurate! Do you want to across the day time, should design a more reasonable solution, CodePudding user response:
references 9 f wxhxj0268 response: Quote: refer to the original poster waterbright response: Use the SetTimer function of the system, set in a long time, across the time of day, time was 78200 seconds, in today's 22:00 Settings, PM the next day, but the problem is that the timing of the trigger delay time delay (experiment 1 minutes and 15 seconds), why is there this problem? For each master It is not a precision timing, 78200 error 75 you see error rate, it has been very accurate! You want to across the day time, should design a more reasonable scheme, For example, what's the plan more reasonable? CodePudding user response:
refer to the eighth floor waterbright response: Quote: refer to the sixth floor jennyvenus response: Timer, really takes place are commonly tooltip disappear automatically, such as programs to stability, especially the time driven program, itself to run for a long time, must be stable and stable than the timer thread, Specific how to operate? Thread every 15 seconds to check the system time, satisfy the corresponding conditions do, other condition called Sleep (15000); CodePudding user response:
If want to in 2015.5.27 11:50:23 performs a specific task, a 1 second timer can be set SetTimer, in checking system time response function (equivalent to check every 1 second time), if greater than 2015.5.27 11:50:23 will destroy timer and execute code, don't think it will take up system resources, hundreds of messages Windows window at any time, don't care much processing a message per second, the measured 0% CPU share, CodePudding user response:
refer to 7th floor waterbright response: Quote: refer to fifth floor VisualEleven response: You can use a tick count thread to timing Specific how to operate? Create a worker thread, WaitForSingleObject (XXX, 1000); A second time, access to current time, ~ CodePudding user response:
Fyi: # include & lt; Stdio. H> #include #include # ifdef WIN32 #include #include #include # define MYVOID void # the else #include #include #include # define CRITICAL_SECTION pthread_mutex_t # define _vsnprintf vsnprintf # define MYVOID void * # endif //the Log { # define MAXLOGSIZE 20000000 # define ARRSIZE (x) (sizeof (x)/sizeof (x [0])) #include #include #include Char logfilename1 []="MyLog1. Log"; Char logfilename2 []="MyLog2. Log"; Char logstr [16000]. Char datestr [16]. Char timestr [16]. Char MSS [4]. CRITICAL_SECTION cs_log; The FILE * flog; # ifdef WIN32 The Lock (CRITICAL_SECTION void * l) { The EnterCriticalSection (l); } Void Unlock (CRITICAL_SECTION * l) { LeaveCriticalSection (l); } Void sleep_ms (int) ms { Sleep (ms). } # the else The Lock (CRITICAL_SECTION void * l) { Pthread_mutex_lock (l); } Void Unlock (CRITICAL_SECTION * l) { Pthread_mutex_unlock (l); } Void sleep_ms (int) ms { Usleep (ms * 1000); } # endif Void LogV (const char * pszFmt, va_list argp) { * struct tm now; Struct timeb TB; If (NULL==pszFmt | | 0==pszFmt [0]) return; If (1==_vsnprintf (logstr, ARRSIZE (logstr), pszFmt, argp)) logstr [ARRSIZE (logstr) - 1)=0. Ftime (& amp; TB); Now=localtime (& amp; TB. Time); nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull