Hello everyone, got another weird one for you. Any ideas why Thread.Sleep would be causing 100% CPU usage?
Basic Raspberry Pi 4 ARM desktop app with a thread added to Window1 with:
Sub Run() Handles Run
Do
System.DebugLog("Test!")
Me.Sleep(1000)
Loop
End Sub
and “Thread1.Run” in Window1’s open event.
Am I doing something wrong? I would expect this to basically do nothing? Funny thing is that running other stuff in for say the event loop, will cause the CPU usage to go down. I did check that it is actually waiting 1000ms with the call to System.DebugLog.
This sounds like an issue I reported a long time ago against 32 bit Linux. The problem was worse on single core CPU but was still too high on multi-core CPUs. Unfortunately, I couldn’t work around the problem.
I’ve just checked Feedback and I cannot seem to find the case I logged (i’m sure Feedback isn’t listing all cases).
I did find this one from several years ago relating to MS-Windows so I guess there are some general gremlins with how sleep has been implemented.
<https://xojo.com/issue/30159>
[quote=462405:@Kevin Gale]This sounds like an issue I reported a long time ago against 32 bit Linux. The problem was worse on single core CPU but was still too high on multi-core CPUs. Unfortunately, I couldn’t work around the problem.
I’ve just checked Feedback and I cannot seem to find the case I logged (i’m sure Feedback isn’t listing all cases).
I did find this one from several years ago relating to MS-Windows so I guess there are some general gremlins with how sleep has been implemented.
<https://xojo.com/issue/30159>[/quote]
After finding out that Thread.Suspend does the same thing, I took another look at the feedback and found this: