MSDN Forum: Why GetTickcount returns 0 in C ++
In Windows Server 2016 standard edition
I am running the developed program (C ++).
I'm using GetTickCount every 30 seconds to get the TickCount value.
① 30 seconds after receiving "2684348122" ms
I got "0" ms when using GetTickCount
Why is this?
Originally, it counts up to 49.7 days, and it is a recognition that you can return that value.
② Continuing from ① above, but when I did GetTickCount again
"30000" ms → 30 seconds later, I got the perfect value for "60000" ms.
Normally, I think it is normal to get a value such as "Example: 30102" ms.
Why are you returning the right value?
Windows development Windows API - Win32
Windows for business Windows Server User experience Other
Developer technologies C++
-
Xiaopo Yang - MSFT • 12,731 Reputation points • Microsoft External Staff
2021-08-20T02:26:52.297+00:00 Could you please show a minimal, reproducible sample without private information?
-
Alfacom大西 • 1 Reputation point
2021-08-20T05:18:06.873+00:00 Thank you
I can't show you the source code
It is possible to show the log.
Is there any problem with the log? -
Xiaopo Yang - MSFT • 12,731 Reputation points • Microsoft External Staff
2021-08-20T07:08:08.09+00:00 Only
GetTickcount
part which produces the log is required. Also please show the log if possible. -
Alfacom大西 • 1 Reputation point
2021-08-20T07:40:09.053+00:00 ①
21/07/20-04:30:52.851[44] [DEBUG ]CMainFrame::ProcessDBMonitor() Called[TickCount=2684318122)21/07/20-04:31:22.855[64] [DEBUG ]CMainFrame::ProcessDBMonitor() Called[TickCount=2684348122)
21/07/20-05:01:09.293[72] [DEBUG ]CMainFrame::ProcessDBMonitor() Called[TickCount=0) ※-->> GetTickCount Return Value 0
②
21/07/20-04:31:59.298[64] [DEBUG ]CMainFrame::ProcessDBMonitor() Called[TickCount=30000)21/07/20-04:32:29.302[01] [DEBUG ]CMainFrame::ProcessDBMonitor() Called[TickCount=60000)
21/07/20-04:32:59.290[44] [DEBUG ]CMainFrame::ProcessDBMonitor() Called[TickCount=90000)
-
Viorel • 122.6K Reputation points
2021-08-20T12:04:20.603+00:00 Did it happen just once? (Did you check other older log files?)
-
Alfacom大西 • 1 Reputation point
2021-08-20T12:47:09.017+00:00 It has occurred only once.
There are only 30 days worth of logs.
As far as I checked all the logs for 30 days, it occurred only once. -
Viorel • 122.6K Reputation points
2021-08-20T12:55:57.873+00:00 Maybe check the system logs using Event View; see if it was something special during that period: suspension, hibernation, updates, system issues, etc.
-
Alfacom大西 • 1 Reputation point
2021-08-20T13:09:04.447+00:00 I checked the OS event log (App, System).
There were no logs of pauses, hibernations, updates, or system issues.The Microsoft Account Sign-in Assistant service has transitioned to a stopped state in the System log.
※Event ID:7036
The WMI Performance Adapter service has transitioned to a stopped state in the System log.
※Event ID:7036But I don't think this log has any effect on OS operation.
-
Xiaopo Yang - MSFT • 12,731 Reputation points • Microsoft External Staff
2021-08-23T05:56:55.667+00:00 I don't think this is
GetTickcount
problem.GetTickcount
has nothing to do with3000
but3000
is the logging interval. -
Alfacom大西 • 1 Reputation point
2021-08-23T07:34:29.327+00:00 Thank You
Yes. As you said, the program tries to get the TickCount value with GetTickCount every 30 seconds.
I think the value returned by GetTickCount is 30000ms.
I think that the program did not calculate 30000ms, but GetTickCount returned the TickCount value at 30000ms. -
Alfacom大西 • 1 Reputation point
2021-08-23T07:37:11.687+00:00 Should I reboot the system ?
-
Xiaopo Yang - MSFT • 12,731 Reputation points • Microsoft External Staff
2021-08-24T02:32:49.063+00:00 It seems that you don't have the source code.. Try monitoring the log to find the regulation.
-
Alfacom大西 • 1 Reputation point
2021-08-24T02:51:31.64+00:00 Thank You
Here is the log.
↓
21/07/20-04:30:52.851[44] [DEBUG ]CMainFrame::ProcessVoistoreDBMonitor() Called[TickCount=2684318122)
21/07/20-04:30:52.851[45] [Info ]Voistore DB Still Connected : Response Time=[0]ms
21/07/20-04:31:22.855[64] [DEBUG ]CMainFrame::ProcessVoistoreDBMonitor() Called[TickCount=2684348122)
21/07/20-04:31:22.855[65] [Info ]Voistore DB Still Connected : Response Time=[0]ms21/07/20-04:31:29.293[72] [DEBUG ]CMainFrame::ProcessVoistoreDBMonitor() Called[TickCount=0) <<-- Here is the value returned by GetTickCount
21/07/20-04:31:29.293[75] [Error ]Last Received Event Tickcount is very long delay : Delay Time = [1610612861]ms
-
Alfacom大西 • 1 Reputation point
2021-08-24T02:52:42.467+00:00 Thank You
Here is the log.
↓
21/07/20-04:30:52.851[44] [DEBUG ]CMainFrame::ProcessVoistoreDBMonitor() Called[TickCount=2684318122) 21/07/20-04:30:52.851[45] [Info ]Voistore DB Still Connected : Response Time=[0]ms
21/07/20-04:31:22.855[64] [DEBUG ]CMainFrame::ProcessVoistoreDBMonitor() Called[TickCount=2684348122) 21/07/20-04:31:22.855[65] [Info ]Voistore DB Still Connected : Response Time=[0]ms21/07/20-04:31:29.293[72] [DEBUG ]CMainFrame::ProcessVoistoreDBMonitor() Called[TickCount=0) <<-- Here is the value returned by GetTickCount 21/07/20-04:31:29.293[75] [Error ]Last Received Event Tickcount is very long delay : Delay Time = [1610612861]ms
-
Alfacom大西 • 1 Reputation point
2021-08-24T02:54:04.993+00:00 The log is here
What does it mean to monitor logs and find regulations? -
Xiaopo Yang - MSFT • 12,731 Reputation points • Microsoft External Staff
2021-08-24T03:00:59.69+00:00 Does it mean the
TickCount=0
always appears afterTickCount=2684348122
? -
Alfacom大西 • 1 Reputation point
2021-08-24T05:34:19.873+00:00 Thank You
21/07 / 20-04: 31: 22.855 [64] [DEBUG] CMainFrame :: ProcessVoistoreDBMonitor () Called [TickCount = 2684348122) and the GetTickCount value was 2684348122.
After that, I got Tick Count
21/07 / 20-04: 31: 29.293 [72] [DEBUG] CMainFrame :: ProcessVoistoreDBMonitor () Called [TickCount = 0) where the value of GetTickCount was 0. -
Viorel • 122.6K Reputation points
2021-08-24T07:43:55.217+00:00 Did you also consider using GetTickCount64 instead of GetTickCount? You must adjust your variables and logging functions.
The problem with GetTickCount seems difficult to reproduce because you must wait 50 days without restarting the system. And, in your tests, it did not always happen. To check your programs, you can try the “Application Verifier” tool (https://social.msdn.microsoft.com/Forums/en-US/f5bbb778-6f0d-4d76-9d41-c56f00d7f8ee), which simulates the wraps. (Also make sure that the observed behaviour was not caused by a tool like Application Verifier, started by someone).
-
Alfacom大西 • 1 Reputation point
2021-08-25T04:26:58.727+00:00 Thank you
The value by GetTickCount is acquired periodically when processing inside the program.
-
Alfacom大西 • 1 Reputation point
2021-08-25T04:52:33.277+00:00 Yes. that's right.
-
Alfacom大西 • 1 Reputation point
2021-08-25T05:04:44.53+00:00 This time the value of GetTickCount was 2684348122.
When I request the next GetTickCount,Returne Value is 0. -
Xiaopo Yang - MSFT • 12,731 Reputation points • Microsoft External Staff
2021-09-01T01:58:04.49+00:00 With only supplying some log text, It‘s insufficient to say
GetTickcount
has problem. Please provide more information.
Sign in to comment