# Threads and Listbox

**URL:** <https://forum.xojo.com/t/threads-and-listbox/9381>\
**Category:** General\
**Created:** [July 8, 2013, 3:38am UTC](https://forum.xojo.com/t/threads-and-listbox/9381 "2013-07-08T03:38:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edwin\_Lau](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/dfb087/32.png) [@Edwin\_Lau](https://forum.xojo.com/u/Edwin_Lau)\
**Post date:** [July 8, 2013, 3:38am UTC](https://forum.xojo.com/t/threads-and-listbox/9381/1 "2013-07-08T03:38:24Z")

</div>

I understand that Updating UI via a Thread is not possible and have implemented the Timer to update the UI which works okay. But it seems ridiculous that just Reading values off the UI is also not allowed which kind of make it very restrictive and hard to work.

I have a listbox which contains files and user inputs which I would need to itinerate through and read in the values to process but not being able to even read the values just makes it almost impossible to work.

It seems like the only way would be to create additional processes perhaps to temporary duplicate the listbox into an array or sqlite table just to get around the UI and Thread issue. I am not sure if this would add to the overhead.

Is there a better or elegant way of getting around this UI Read/Thread restrictions apart from abandoning Xojo and going back to RealStudio 2012 ?

---

<div class="post-metadata">

**Author:** ![Brad\_Hutchings](https://forum.xojo.com/user_avatar/forum.xojo.com/brad_hutchings/32/143_2.png) [@Brad\_Hutchings](https://forum.xojo.com/u/Brad_Hutchings)\
**Post date:** [July 8, 2013, 3:47am UTC](https://forum.xojo.com/t/threads-and-listbox/9381/2 "2013-07-08T03:47:30Z")

</div>

> [@18652:@Edwin Lau](#):
>
> But it seems ridiculous that just Reading values off the UI is also not allowed which kind of make it very restrictive and hard to work.

If you really understand the issues of thread safety, it doesn’t seem so ridiculous. That said… The straightforward way to handle this is to create a subclass of Timer, call it ListBoxTimer. In the timer’s action, make the changes to the ListBox that are queued up, then read the values you need and store them as properties of ListBoxTimer for easy access from the Thread.

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [July 8, 2013, 4:31am UTC](https://forum.xojo.com/t/threads-and-listbox/9381/3 "2013-07-08T04:31:04Z")

</div>

If the contents of the listbox aren’t supposed to change while the thread is running, copy the contents of the listbox into an array before running the thread. The thread can use the array instead of the listbox.

---

<div class="post-metadata">

**Author:** ![Tim\_Jones](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_jones/32/8627_2.png) [@Tim\_Jones](https://forum.xojo.com/u/Tim_Jones)\
**Post date:** [July 8, 2013, 4:58am UTC](https://forum.xojo.com/t/threads-and-listbox/9381/4 "2013-07-08T04:58:09Z")

</div>

Tim’s recommendation is the path I took when I threaded my apps. Since the array members align to the list position, accessing theArray(theSavedListIndex) is the same contents as the selected line in the listbox. However, I’ve had to get fancy with a multi-selection listbox where I have a separate variable that contains the selected listindex values.

---

<div class="post-metadata">

**Author:** ![Edwin\_Lau](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/dfb087/32.png) [@Edwin\_Lau](https://forum.xojo.com/u/Edwin_Lau)\
**Post date:** [July 8, 2013, 4:59am UTC](https://forum.xojo.com/t/threads-and-listbox/9381/5 "2013-07-08T04:59:22Z")

</div>

I am experimenting with Arrays now. Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 4:44pm UTC](https://forum.xojo.com/t/threads-and-listbox/9381/6 "2020-10-29T16:44:23Z")

</div>


