Timer is not working properly

[quote]This is one of the reasonable uses of app.DoEvents. I’ve implemented
synchronous methods in this way in console apps. I expect that it
would work in GUI apps as well.[/quote]
You should read the docs on this:
http://documentation.xojo.com/index.php/Application.DoEvents

As the docs say its intended for Console apps and that is why it worked for Charles in a console app. Maybe if you change the structure of the app to not use DoEvents it will work as you expect? If you are relying on DoEvents you can probably split up the code in the loop into a timer or a thread with no issues.

Wouldn’t Poll be safer? At least you wouldn’t inadvertently trigger other events that way.

Seven years ago, we did not know what we know today. Seven years ago, I might have thought DoEvents in a gui app was ok too. But today we know it should never be used in a gui app. The alternatives might take more code, but there’s always another way.

IMHO, whenever one finds necessary to use DoEvents in a Desktop app, it is the mark of procedural thinking. Being an old dinosaur, I had to wrap my head around event driven in the past, and now can spot old thinking miles away. Does not mean I am immune to the tight loop mirage. Old habits die hard.

Long tight loops are the major place where DoEvent becomes necessary. They have been used in the past in AppleSoftt Basic, Apple Pascal, GWBasic, Basica or QuickBasic in the archaeological times before event driven programming.

In an event driven environment such as Xojo, whenever the temptation to use a tight loop arises (“because it is easier”), the first reflex should be to use a timer. Instead of a for-next, do the same in a timer and no need for DoEvents.

And if you REALLY want to use a tight loop, do it in a thread. I verified it does not freeze the main loop.

DoEvents are fine in Console apps, though, and Greg confirmed it is fine in Web apps that are intrinsically dressed-up Console apps.

What I would really love is to be able to evidence the bad effects of DoEvents, to settle the controversy once and for all. There must be ways of creating bugs with it that suffer no doubt. After all, reentry can be detected.