wimpie3 Well-Known Member Licensed User Longtime User Mar 10, 2016 #1 I have a lot of subs launching downloads with OkHTTPUtils2, like this: Code: Copy Dim httpjob As HttpJob httpjob.Initialize("getImage", Me) httpjob.GetRequest.Timeout = 5000 httpjob.Download(fileURL) I don't have a global dim'med HttpJob, but I create a new one for every request. My question is: how do I cancel all those downloads at once? I don't have a reference to them anymore as they are all individually dimmed inside subs. Can I loop over all objects in memory somehow, look if they are of the type "httpjob" and cancel the downloads?
I have a lot of subs launching downloads with OkHTTPUtils2, like this: Code: Copy Dim httpjob As HttpJob httpjob.Initialize("getImage", Me) httpjob.GetRequest.Timeout = 5000 httpjob.Download(fileURL) I don't have a global dim'med HttpJob, but I create a new one for every request. My question is: how do I cancel all those downloads at once? I don't have a reference to them anymore as they are all individually dimmed inside subs. Can I loop over all objects in memory somehow, look if they are of the type "httpjob" and cancel the downloads?
JordiCP Expert Licensed User Longtime User Mar 10, 2016 #2 You can keep a reference to these objects adding them to a list/map when you create them Upvote 0
wimpie3 Well-Known Member Licensed User Longtime User Mar 10, 2016 #3 Good idea, but I imagine there must be another way? In VB you can loop over all elements, check what type they are, etc... Upvote 0
Good idea, but I imagine there must be another way? In VB you can loop over all elements, check what type they are, etc...
DonManfred Expert Licensed User Longtime User Mar 10, 2016 #4 See this: https://www.b4x.com/android/forum/threads/download-huge-files-with-httputils2.30220/ Note the changed bas files. this allows you to stop a download job Last edited: Mar 10, 2016 Upvote 0
See this: https://www.b4x.com/android/forum/threads/download-huge-files-with-httputils2.30220/ Note the changed bas files. this allows you to stop a download job
wimpie3 Well-Known Member Licensed User Longtime User Mar 10, 2016 #5 As far as I can see, each download job should have a different name in that lib. That's not what I'm looking for. Upvote 0
As far as I can see, each download job should have a different name in that lib. That's not what I'm looking for.
Erel B4X founder Staff member Licensed User Longtime User Mar 10, 2016 #6 The name is not important. See how CancelDownload(url As String) is implemented. You can modify it to cancel all the jobs. Upvote 0
The name is not important. See how CancelDownload(url As String) is implemented. You can modify it to cancel all the jobs.