DoEvents alternative

Since using Xojo 2024r3(.1) causes segfaults on Linux (https://tracker.xojo.com/xojoinc/xojo/-/issues/77679)

Does anyone know of an alternative way to prevent a console service application from exiting than using DoEvents in a while loop in the App Run Event Handler?

Until I’ve found an alternative; Xojo 2024R3.1 is unusable for me.

Hi Robert:
I went back to 2023R4 with cooperative threads - faster and minimal doevents (I am on Windows)… 2024R3 is not ready for prime time …

1 Like

if DoEvents (for console app) is not essential maybe
Thread.SleepCurrent(100)

(because just a loop is somehow a electrical short.)

For threads this indeed has alway been the only correct way. For console apps, that need to keep running, DoEvents in a loop in the main Run Event seems to be the only way to keep an app alive…

my test was just a

Do
 Thread.SleepCurrent(100)
Loop

in this Run Event and the console stay open until i closed it from ide, tested at windows 11

DoEvents is named accurately. The proper way to keep a Console app alive while receiving events is DoEvents, not Sleep.

If console apps and DoEvents are broken, 2024r3(.1) should be pulled and apology issued.

See: Preemptive thread weird behaviour with DoEvents and Thread.Sleep

Thread.Sleep, Thread.SleepCurrent, and DoEvents are quite messed up right now in 2024r3(.1), Although, from my testing, this is only the case with 1 or more preemptive threads active. I won’t be using 2024r3(.1) until threading is stable again. I already have issues with 2024r2.1 and don’t need to add any more. (Offending code in 2024r2.1 does not seem to be any different in 2024r3(.1) so probably not fixed)

DoEvents isn’t broken in 2024r3.1 and TargetLinux.

E.g. this works without issues (and it obviously uses .DoEvents to keep the Console App running):
sworteu/Express: Express is a Xojo API 2.0 compilant speed optimized webserver

It looks your issue is related to URLConnection (according to William’s Remark on Issue 77679).

And there are alternatives to URLConnection… e.g. MBS Curl, or the OpenSource charonn0/RB-libcURL: A Realbasic and Xojo binding to libcurl… but yes, it’s a bit annoying that URLConnection seems to have issues in the current Xojo Version.

2 Likes

Indeed it seems to have been a combination of URLConnection and DoEvents; The fix will be in 2024r4’s URLConnection. I’ll be waiting for that instead of reworking a ton af API calls to MBS Curl.

1 Like

Redacted by me from William’s notes:

[Not] about App.DoEvents crashing but primarily involves a bug that occurs when URLConnection.Disconnect is called while concurrent asynchronous sessions are still active. [For 2024R4] URLConnection.Disconnect now correctly aborts an asynchronous session, preventing crashes that could occur if App.DoEvents is called *an unexpected reentrant event loop action is fired by the user* during the connection’s shutdown process.