From Xojo Documentation

Revision as of 17:46, 19 October 2020 by PLefebvre (talk | contribs) (Notes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

ConsoleApplication.DoEvents([milliseconds As Integer])

Supported for all project types and targets.

Yields time back to your app so that it can handle other events.


By design, console applications do not have a main event loop. It implies that classes relying on such event loop will not work as expected.

You can call DoEvents in the Run event of your console application to create your own main event loop. If you use Timers or sockets in a console application and fail to periodically call App.DoEvents, sockets will not work and Timer.Action will never fire.

Specifying zero milliseconds causes the next waiting thread to execute. A negative value specifies no sleep. The default is -1.

Web Applications

Calling this in a web application from any event of WebSession, WebControl or any WebControl subclass will raise an exception. If you're trying to update the browser, call UpdateBrowser instead.

Sample Code

// In the Run event of your console application

Var consoleTimer As New MyTimerSubclass
consoleTimer.RunMode = Timer.RunModes.Multiple // Don't forget this one
consoleTimer.Period = 1000 // Call every second


where myTimerSubclass is a subclass of Timer whose Action event holds the code you want to run each time the timer is called. Since this creates an infinite loop, press Control-C in the terminal to stop the app.