Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 5.4

COLUMN

A Simple Threaded Application

Threads Keep The UI Responsive

Issue: 5.4 (May/June 2007)
Author: Charles Yeomans
Author Bio: Charles is the author of "I Declare: Calling External Functions in REALbasic", available online at http://www.declareSub.com/
Article Description: No description available.
Article Length (in bytes): 5,485
Starting Page Number: 41
Article Number: 5415
Resource File(s):

Download Icon 5415.zip Updated: 2007-05-18 10:50:08

Related Web Link(s):

http://www.declareSub.com/
http://www.nilobject.com/2005/12/08/holiday-treat/

Excerpt of article text...

Long-running methods can prevent the user interface from being updated. This is an annoyance for user, and thus a problem for many developers. The solution is simple enough: execute such methods in a separate thread.

Unfortunately, some developers attempt to take what appears to be the easy way out by calling App.DoEvents to cycle the event loop. This can lead to serious problems with unexpected reentrancy. If you don't know why this is dangerous, then you surely should not be calling DoEvents. If you think you do, then you can use DoEvents, since it is a documented method. But don't expect any sympathy from the Real Software engineers if you encounter problems.

And, assuming that you "know what you're doing," there remains the problem of calling App.DoEvents. Presumably you would call it from within the long-running method. This entangles the method implementation with the user interface, assuming that you can do this -- perhaps you're using an encrypted class.

...End of Excerpt. Please purchase the magazine to read the full article.