Link thread to run with method

Hi All,

I have an application that uses a bash script to load files and folders into a listbox. Depending on the size of the data, this action can lock up the screen for quite some time. How do I get my thread to act on the method that runs the bash script to get a progress bar to display the process and free up the main application?

Roger

See either of the example projects in the Xojo folder under the topic UpdatingUIFromThread

While a thread cannot touch the UI without giving an Exception, it can read and write to variables. I write to a percentComplete variable which a Timer displays. I can also get the thread to look for a Cancel Boolean variable to know if its time to quit early.

Hi David,

Do you have a brief example of how to do that? I have been banging my head against the wall with this for a while now with no luck.

Roger

Examples:

I have looked at the underpinnings of the Thread.Run action. Documentation says it can run a method from within it. However, when I try to do just that, the application hangs and reports being Unresponsive. Any ideas?

To add to Paul’s helpful links, here is a free book on threads and timers:

I Wish I Knew How To …Program Threads and Timers With Xojo

[quote=371510:@Eugene Dakin]To add to Paul’s helpful links, here is a free book on threads and timers:

I Wish I Knew How To …Program Threads and Timers With Xojo[/quote]
The link on that page reports a 404.

Hmm, that’s weird. There must be something wrong with my iPhone. Try http://scispec.ca and click on the ‘books’ tab to search through the books.

It’s not the forum link to the page that’s broken, it’s the download link that’s on the page that’s broken :frowning:

Ok, thanks Tim. I will need to fix the link when I get to my development computer tonight. Thanks :slight_smile:

I also tried to download the Threads On / Off example from the Xojo Bits area and the download link there is also broken.

What does your code look like? Are you starting the Shell in Asynchronous mode rather than Synchronous mode?

The link is repaired for downloading the book. For some reason the website automatically deleted any file with a .zip suffix… I am repopulating the site now, and you should be able to download the book at the website:

Threads and Timers

Sorry for the inconvenience.

Thanks Eugene :smiley:

Hi Paul,

I am running my shell scripts using the .WriteLine to generate interactive shells .

Eugene,

Just downloaded the examples. Looking forward to checking them out.

Hi All,

Let me try to explain more clearly. My app has a main window with a toolbar. When I click on one of the buttons, a sheet window appears to provide the user with certain functionality. One of those functions is to be able to press a button and have a listbox populate with the path of the selected files and folders and to calculate the size of those items. Depending on the size of the data, this can cause my application to freeze until it is done. Sorry, this is done WITHOUT having to use a shell script. I was thinking of another button that launches a shell script.

Is it even possible, in this scenario, to have a progress bar that indicates the time to finish and allow the user to interact with the app while the process is running? If so, where would I put the Thread & Timer to make this happen.

I apologize for the lack of substance on my earlier posts.