DisableBackgroundTasks and Worker

Hi all !
Did anybody notice that DisableBackgroundTasks (or BackgroundTasks False) avoids Worker to be started or to run?
I’m using this Pragma command in a Thread (in order to accelerate calculation). Beside this thread, I launch a Worker. Doing that, the Worker never starts or runs (easily verified with the Activity Monitor utility).
Converting the Pragma into a comment, the Worker works very well.

iMac 2020, Monterey 12.01, Xojo 2021r3

Any explanation or idea ?
TIA
DocJLA

An example project would be very helpful as your explanation is a bit vague.

I will try with Xojo example of Worker. Either DisableBackgroundTasks blocks the Worker, and there is something wrong, or it does not, and I’m wrong! I will let you know ASAP.

That‘s not surprising when you‘re running a Debug Build; here a worker is a Xojo thread that will be blocked.
Have you tried in a regular built app?

My apologise! I should have written that I tested it in a compiled App, of course.
Running in the IDE, with ou without DisableBackgroundTasks, it always works, because of the Worker being simulated through Thread.
Thanks for replying!

DocJLA

Maybe Xojo starts the worker app in a thread, which is then blocked by “DisableBackgroundTasks”… Then probably only someone from Xojo can answer.
I use “DisableBackgroundTasks” only very rarely, but usually only in the main thread. It rarely if ever makes sense to do things in a thread (which is a background task) and then block everything else. :thinking:

It’s better tp have the worker behave exactly the same in debug as in actual builds. The thread in debug makes it very hard to actually simulate the behaviour that’s expected. The thread would never actually be shipped. Maybe xojo should cache the worker if no code had been changed and in debug build just run the cached (unless changes have been made in the worker code)

2 Likes
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.