Archived Forum Post

Index of archived forum posts


Example "Send Email Asynchronously using a Task" not really async for Xojo

Mar 03 '17 at 08:52

I'm trying to send mails with the above example. Sending the mail works fine. However, with the task the UI shouldn't be frozen. Instead I get the pizza and my progress wheel doesn't show up.

Bug, feature, am I doing something wrong?

Xojo 2016r4, Chilkat plugin from June. Mac OS 10.11.

Mit freundlichen Grüßen/Regards

Beatrix Willius Mail Archiver X: The email archiving solution for professionals

Accepted Answer

The purpose of the example isn't that you would copy-and-paste the code verbatim.

The example does the following in sequential order:

  1. Starts the async task to send the email.
  2. Waits for it to complete.
  3. Examines the results after the task completed.

Your actual Xojo code would perform each step separately. You would write a Xojo function/subroutine to start the async task, and then return.

Then you would implement some means to periodically check for the task completion. Maybe a timer event? The checking can be quite often (multiple times per second) without noticeably affecting UI performance. When your app notices the task has completed, you then do step 3.

Your app would never do steps 1, 2, and 3 altogether as shown in the example, because (of course) it would freeze the UI because control is not returned to the main event loop..


Sorry, my bad. You know those lazy developers that only do copy and paste.

I had wondered about the code. But since it compiled I tried it. It was the line with dim xxx as task that confused me. This really indicated to me that the task was a local variable and not a property of the window.

The MBS guy converts his examples to html (see for instance) so that it's way easier to see how the code is used.


Beatrix Willius


Follow-up: the root cause of the issue was that I was adding more than a couple of attachments which had to be zipped first. This was causing the spinning pizza of death to show even when the task was used correctly. With a thread and a timer everything now is sent in the background.