Raspberry Pi Thread.Sleep Causes 100% CPU Utilization

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.

Any help would be very much appreciated!

It would also appear that Thread.Suspend does the same thing. The only way for me to sleep a thread is to kill it and then resume with a timer.

What happens if you use App.SleepCurrentThread(1000) instead of Me.Sleep(1000)? Do you get a different result?

Just curious.

[quote=462331:@Scott Cadillac]What happens if you use App.SleepCurrentThread(1000) instead of Me.Sleep(1000)? Do you get a different result?

Just curious.[/quote]

Same Issue sadly ;(

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.
feedback://showreport?report_id=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.
feedback://showreport?report_id=30159[/quote]

After finding out that Thread.Suspend does the same thing, I took another look at the feedback and found this:

feedback://showreport?report_id=56420