read a variable from a thread.

mac os

I am trying to compute a progressbar progress using a thread and timer.

a thread cannot read any variables from a main thread.

how can I read a computed value inside a thread?

Have you checked the exemple “UIThreadingWithTask”?

no where cam i find the example.

You are mistaken. A thread can’t touch the UI, but it can read/write variables from anywhere.

Tim

In the Xojo online manual this is what is says about a tread::

Do not access any built-in property or method of a user interface control or Window from within a Thread as platform UI frameworks are not thread-safe. Doing so raises a ThreadAccessingUIException. See below for additional information.

David… what you posted is true, and perhaps Tim’s “anywhere” was a bit too broad :slight_smile:

If you define a global variable in a module … .then it can be accessed by any thing at any time… what you cannot do is access the “BUILT IN” properties or methods of a control… ie. you cannot alter the the UI. Threads are process execution paths… and don’t affect the scope of variables.

dave

that is true.
In a test a thread can access a global. my progress bar still does not work, but that is another issue.
I do not understand what UI is. ( User Interface )?

User Interface. https://en.wikipedia.org/wiki/User_interface

ahh got it.
thanks

A thread can also access properties that you have added to a window or a control subclass, just not the built-in ones.