Using timeBeginPeriod and CreateTimerQueueTimer has been working for me quite long on the few computers I used it to get a timer with e.g. 1 ms resolution, but now I came across several other computers, where this does not work anymore and I only get a 16 ms resolution.
Not sure if that's relevant: The computers on which it is working as excepted and on which it is not working all run the same Windows 10 21H2 with the same antimalware and are administrated by the same department.
I use basically the same code as in this Microsoft example together with a timeBeginEvent(1).
Interestingly, clockres64 from Sysinternals reports Current timer interval: 1.000 ms, and powercfg -energy duration 5 lists my app with the information Requested Period 10000, still the resolution is 16 ms.
What am I missing, which other API function do I have to call to get a timer with a 1 ms resolution?
Update: Same behavior when using NtSetTimerResolution.
Related
The Mac has decided to freeze and restart several times a day while I'm using it.
panic (cpu 2 caller 0xffffff801a579938): watchdog timeout: no checkins from watchdogd in 93 seconds .....
Used the repair disk utility tool multiple times in different recovery modes.
I Used every free admin fixing tool, clean up tool and error reporting tool on the app store.
Launched my Mac in all sorts of different recovery modes. I literally pressed and used every restart keyboard combination you can with a Mac. And I used them several times over and over in different scenarios.
Spent hours researching every forum and reading every article of similar problems and solutions.
Download the manual updates and installed them each separately
After a day of frustration i found then solution
The fans internal sensor wasn’t working any more.
I set the automatic controls using Macs Fan Control app and in Custom switched to Sensor-based value and selected CPU PECI from drop down and set 30 in Temperature that the fan speed will start to increase from and 90 in Max temperature. Fans now kicking in and cooling down the processors and preventing from re-starting.
Source
I've an application that requires timers with 1msec precision. Under windows I call timeBeginPeriod(1) at the begin of main() to ensure 1msec resolution (and timeEndPeriod(1) before program exit). I've some threads that perform periodic activities that use WaitableTimer/WaitForSingleObject to sleep for the required time period.
Sometimes the application starts and works fine (sleep times are correct). Other times the application starts and the timer gets fired at a multiple of 15msec (6 msec timers fired at 15 msec, 20 msec timers fired at 30 msec). If I run the TimerResolution application, it reports that the Windows timer resolution is 1msec (0,997 msec), but yet timers are not fired correctly. If I simply restart the computer, timers return working fine.
I've found the problem occurring on Windows 10 1803, 1909 and 2004. I know timer resolution handling was changed since Windows 2004, but I thought that the problem was not present on previous Windows 10 versions.
Any idea where I can look at into Windows when the problem shows up, in order to understand why timers are not properly fired ?
Thanks,
Massimo
My office recently transitioned from running Windows 7 to using remote desktop sessions running on Windows Server 2012. Some VBA macros I was using include calls to the "Beep" function in the Windows API, which I used as an audio alert that execution had completed. This is the version of "Beep" that takes in a frequency parameter and a duration parameter, and plays a beep of that frequency in Hz for that duration in ms. On the new system, however, no sound is played, and there is no delay after calls to the function. Did Microsoft remove the Beep function in Server 2012?
EDIT: this is a different question than the linked discussion about Beep in Windows 7. I was previously using this code on Windows 7 without any problems. I have checked that my computer's speakers are turned on, that they are plugged in, and that the system volume is not muted. The behavior here is that Beep() is being treated as a null; nothing happens when it is executed. If the sound were simply muted, the code would at least delay until the indicated number of milliseconds had elapsed; instead, Beep() is skipped like it's not there at all in my code. Take, for example, the following code:
Sub beepTest()
k = Beep(523, 5000)
MsgBox("All Done!")
End Sub
On the old Windows 7 system, the computer would play a tone over the plugged in speakers for 5 seconds, then pop up with the message box. When running inside the Server 2012 RDP, however, the call to Beep() is essentially ignored, and the message box appears instantaneously, without a 5 second delay. This means that it can not be just an unplugged or muted sound device; if it were, there would be no sound audible, but there would still be a delay, similar to calling the Sleep() function. I wanted to know whether Microsoft had possibly removed support for this API in Server 2012, which would explain why my code isn't working as intended.
I just read that while Windows Phone 7.5 background tasks can poll for a location, they don't actually poll real-time from the GPS but rather the location API calls return a system-cached position that's only updated once every fifteen minutes.
That limitation of course completely invalidates any attempt at having navigation run in the background as you can get pretty damn far off-track in fifteen minutes, let alone that a background task can only run once every thirty minutes or so!
That said, Nokia's navigation app and reportedly Runtastic's app do continue tracking when in the background (i.e. not just under the lock screen) and both are in the marketplace meaning they have been approved, so does anyone know how they managed to do what the SDK supposedly doesn't support?
For reference, we don't actually need real-time tracking... maybe once a minuted or so, and we don't need that much accuracy... maybe 100 feet or so... but we do need more than we have been given. We just don't know how they're doing it in approved apps.
You'll only be able to retrieve the location when your PeriodicTask executes (Approximately every ~30 minutes, depending on OS scheduling). The location data it fetches from GeoCoordinateWatcher will be from the OS's cache rather than directly from the GPS hardware. If nothing is running the OS will update this with coarse-grained data approximately every 15 minutes. However if an application has executed and retrieved fine-grained GPS hardware data than this will be the data you'll retrieve in your PeriodicTask. You can see examples of this by accessing the GPS in your foreground app and force-scheduling your PeriodicTask with ScheduledActionService.LaunchForTest.
Based on my experience with background tasks, you will not be able to achieve what you want with either Periodic or ResourceIntensive background tasks.
Despite documentation claiming that they run every 30 minutes, my experience is that they run sporadically and unpredictably. Over the last 14 hours, my app's periodic task has run a total of 6 times, and this is pretty consistent every day - it runs about once every two hours. For resource intensive tasks, I find they usually run about twice a night. I guess the OS has to balance all the processes on the phone and all the other apps clamoring to run their background tasks, so sometimes yours doesn't make the cut. Obviously, your mileage may vary based on your phone (lumia 800 in my case) and the apps you have installed.
If you want to write an app that tracks your location once a minute, my advice would be to enable it to run under the lock screen by disabling idle detection and make sure it has a low memory footprint to conserve battery life.
I just moved from WinXP to Win7.
My software needs to have real time response to I/O so it makes a busy-wait in one thread (which has affinity to run on one CPU).
The result is 100% CPU on one of the cores and 0% CPU for others, on Winows XP it worked just fine.
In Windows 7 the system freezes. (The software is a console application, for Windows application it behaves a bit different. only if the main thread make busy-wait without peeking messages it freezes)
Any ideas ?
So you're using a non real-time OS for realtime I/O. Simply put the code isn't working correctly and should do a non busy-wait (change to a sleep-wait) loop and change the thread timer settings to something that is realtime enough.
See this question to setup windows for millisecond precision on a timer callback.
How to trigger a C# function at a certain time with millisecond precision?