MBS Xojo Conference
6/7th September 2018, Munich

« Xojo Stammtisch in Be… | Home | Happy Easter 2018 »

Query all threads in Xojo app


As you may know Xojo has internally a list of all objects, but does not provide an official way to quickly (!) query all thread objects. Of course we could manage ourselves a list of thread objects, but that is inconvenient for projects with a lot of thread subclasses. A few years ago I made a feature request for a threads list: Feedback Case 26912.

As we just needed this today, we got the following function to find all thread objects in memory. We need this in an app to cancel all transfers when the app is quitting:

Function Threads() As Thread() #pragma DisableBackgroundTasks true dim threads() as Thread Dim o as Runtime.ObjectIterator = Runtime.IterateObjects While o.MoveNext dim v as Variant = o.Current if v isa Thread then threads.append v end if Wend return threads End Function


Sadly runtime's IterateObjects method is quite slow as it does some introspection stuff which takes a lot of time (see Feedback case 47148. Probably to filter some objects from the list, which we should not see here. But maybe the method above is still useful for you?
28 03 18 - 19:54
No comments

  
Remember personal info?

Emoticons / Textile


Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.