Label and thread with xojo2013r3.1

Hi,
when I write in text label via thread the content that works fine with xojo2013r2 but not with xojo2013r3.1!
Do you know that problem?
With MAC OS work’s that project fine - 2013r2 and 2013r3.1!

For example:
This code isn’t possible in a thread with xojo2013r3.1 (Windows7)!
summeFrames.text = “Test”

bye
Klemens

You cannot access the user interface from within a thread. This should not have been possible from Xojo 2013 r1.

Edit - This was not possible on mac from Xojo 2013 r1 not sure about windows but perhaps it has been disallowed in recent versions to keep the concept of UI access across all three platforms consistent.

Since 2013r3.1 (i think) it not allowed to change the UI or a build in property of the UI from within a Thread on Windows, Linux and OS X Cocoa.

It is still possible on Carbon, because it’s deprecated. (It just does not raise an exception on Carbon)

[quote=40736:@Sascha S]Since 2013r3.1 (i think) it not allowed to change the UI or a build in property of the UI from within a Thread on Windows, Linux and OS X Cocoa.

It is still possible on Carbon, because it’s deprecated. (It just does not raise an exception on Carbon)[/quote]

BTW: This is no Xojo restriction. It is not allowed in general. Only the Main Thread should be allowed to change the UI. :slight_smile:

I have written a Label subclass which is thread-safe - it uses computed properties which which, if called from within a thread, will automatically trigger an update on a Timer callback.

It’s not foolproof : the main thing is that you have to be sure to declare variables as the Timer subclass, not as just Timer (otherwise, the computed properties getters & setters in the subclass won’t be called).

One of these days I plan to make this code open source and start a GitHub (or similar) repository, or add them to MacOSLib etc.

Starting with Xojo 2013 Release 3, Threads on Windows and Linux cannot access UI components (controls, windows or their properties and methods). This was also true for Cocoa starting with Xojo 2013 Release 1. For more information:

[quote=40773:@Paul Lefebvre]

I believe the link is wrong there, it should be : http://documentation.xojo.com/index.php/Task right?

Also, when was Task announced? I must have missed it.

Yes, you are right. I’ve updated my post.

It was first included with Xojo 2013r1. I guess it was first announced in that blog post I mentioned.

[quote=46535:@Paul Lefebvre]Yes, you are right. I’ve updated my post.
It was first included with Xojo 2013r1. I guess it was first announced in that blog post I mentioned.[/quote]

The blog post mentions an example file in Desktop/Threading/Tasks but I’m not seeing it, at least not in 2013 R 3.2 - is it missing?

They were moved in a subsequent version. The examples are now here:

Examples/Desktop/UpdatingUIFromThread/UIThreadingWithTask
Examples/Desktop/UpdatingUIFromThread/UIThreadingWithTimer

Found it, thanks.