[sharing] efficient app.DoEvents replacement

It is, but letting a user enter code to be executed on your server… I’m not sure there are worse ideas.

[quote=373342:@Asis Patisahusiwa]Simple test

//PushButton1
Sub Action() Handles Action
  Thread1.Run()
End Sub

//Thread1
Sub Run() Handles Run
  me.Sleep(100*1000)
End Sub

CPU usage: 75%.[/quote]

Now try this with Thread1.Priority = 4 (or lower, up to 1)
Default priority is 5, higher value gives less processing time.

If i do that, then I need to create a simple parser and then create a class on the fly (Xojo doesn’t support that).

I hope XojoScript have Ptr datatype or we can use AddHandler or a Delegate, Or passing object datatype back to Xojo code.

[quote=373422:@Derk Jochems]Now try this with Thread1.Priority = 4 (or lower, up to 1)
Default priority is 5, higher value gives less processing time.[/quote]
Tried that already, setting priority to 1, still cause high CPU usage.

It should definitely not do that. It does not under Mac or Windows. You should file a bug report for Linux.

This issue has been reported in 2008 and marked as a fixed issue in 2015R3. I’ll check that version.
<https://xojo.com/issue/370>

[quote=373509:@Asis Patisahusiwa]This issue has been reported in 2008 and marked as a fixed issue in 2015R3. I’ll check that version.
<https://xojo.com/issue/370>[/quote]
Same issue. Still, high CPU usage.

Tested this on console app

dim x as Integer
While True
    x = x + 1
    Print "X = " + Str(x)
    DoEvents 1000
Wend

CPU usage: 0.0%

What linux distro and version are you using?

Which test? console?

I tested console code on Arch Linux, Xojo 2016R4.1. Use htop to see application’s CPU and memory usage.

What version of arch linux are you using?

arch linux is Rolling release distro. I use Arch Linux x86_64 (latest update).

Thanks, I wanted to take a look, I’ll let you know if I find anything. Time to access the 20+ year old unused linux knowledge from the dark recesses of my grey matter.

Check this. CPU = 0.0%, Memory = 0.1%.

[quote=373509:@Asis Patisahusiwa]This issue has been reported in 2008 and marked as a fixed issue in 2015R3. I’ll check that version.
<https://xojo.com/issue/370>[/quote]

You want to open a new case. The other one is closed now. Just mention in yours that it is apparently a regression, and link to 370.

At any rate, it should be fixed. The only way to get attention from Xojo engineers is a bug report.

In practice, you may want to test with 2015R3, since Travis hill apparently tags it as fixed.

Please share your entire test project. I feel like there’s something we’re missing.

High CPU usage test:
https://www.dropbox.com/s/moos64iukk7m988/high-cpu-usage.xojo_binary_project

Console test:
https://www.dropbox.com/s/fydhlo1j8004fsx/console.xojo_binary_project

[quote=373581:@Asis Patisahusiwa]High CPU usage test:
https://www.dropbox.com/s/moos64iukk7m988/high-cpu-usage.xojo_binary_project

Console test:
https://www.dropbox.com/s/fydhlo1j8004fsx/console.xojo_binary_project[/quote]

You should attach the one that demonstrates the high CPU usage to your bug report.

I solved this issue by creating a simple Linux plugin to provide delay function. Now, average CPU usage is 10.0%.

Thank you all. I’ll create feedback for this issue.

[quote=373627:@Asis Patisahusiwa]I solved this issue by creating a simple Linux plugin to provide delay function. Now, average CPU usage is 10.0%.

Thank you all. I’ll create feedback for this issue.[/quote]
Well for what it’s worth, that high usage test project has nothing weird about it that I was expecting to see.