Android Question best way for download by httputils in a loop for

ArminKH

Well-Known Member
Hi
I have a loop for and download a list of pictures
Now my question is:
Which way is better?
1.dim and initialize a job for each item in loop for(i dont want to download all items together)
2.Use single job for all items
I looking for a way which have less cpu and ram usage
I know we have image downloader class but for some reason thats not usable for me
Please suggest best way
Thanx
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
You should not hold the main thread in a For Next loop. Instead use the job done event to check if another image requires downloading and trigger it from there.
 
Upvote 0

ArminKH

Well-Known Member
You should not hold the main thread in a For Next loop. Instead use the job done event to check if another image requires downloading and trigger it from there.
My for next loop is for add search relust,my download start again from jobdone
My question is about dim job
At first i dim a job and initilize that then start download
Now if job success then we must dim a job with same name ? Or is better to use first job and not dim new one?
Which way is fast and use less cpu and ram?
 
Upvote 0

ibra939

Active Member
Licensed User
Longtime User
My for next loop is for add search relust,my download start again from jobdone
My question is about dim job
At first i dim a job and initilize that then start download
Now if job success then we must dim a job with same name ? Or is better to use first job and not dim new one?
Which way is fast and use less cpu and ram?

there many thing want to do but still i don't see one example for donloading mp3 or media as perfect .
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
My for next loop is for add search relust,my download start again from jobdone
My question is about dim job
At first i dim a job and initilize that then start download
Now if job success then we must dim a job with same name ? Or is better to use first job and not dim new one?
Which way is fast and use less cpu and ram?
I declare and initialise the Http job in a function each time. I've never had any problem in doing this as I believe it is only stored as a local object and so only held in memory for as long as it is referenced. I could be wrong with my explanation, but as I said I've not had any problems in doing it this way.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Now if job success then we must dim a job with same name ? Or is better to use first job and not dim new one?
ALWAYS create a new instance of the httpjob. You can give it the same name.
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
Upvote 0
Top