Query all threads in Xojo app
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?