1

I am trying to build an mobile app (iOS and Windows) that downloads a list of audio files from remote server.

Is there any criteria one needs to consider before using different threads for downloading the files concurrently. (Basically i need to download 7 files concurrently.)

I found in case of iOS there is a parameter

"NSOperationQueueDefaultMaxConcurrentOperationCount" which decides the count of concurrent operations allowed. Is there any other parameter that i need to consider while developing for iOS/Windows

Kindly guide me , i am newbie to mobile development.

Regards Robert

Avijit Nagare
  • 8,482
  • 7
  • 39
  • 68
Robert
  • 11
  • 2
  • Check this answer to do it in your ios app http://stackoverflow.com/questions/13996621/downloading-multiple-files-in-batches-in-ios – LoVo Feb 08 '16 at 07:47
  • For `iOS`, you want to use the `NSURLSession` and `NSURLSessionDownloadTask` classes. – Robotic Cat Feb 08 '16 at 08:09
  • @Lovo thanks for the link, Will try this. – Robert Feb 08 '16 at 14:35
  • @ Robotic, Yeah if that allows me to download multiple files concurrently. Please guide me if any issues with this, or some other better alternative exists – Robert Feb 08 '16 at 14:37

1 Answers1

0

Interestingly here it states that NSOperationQueueDefaultMaxConcurrentOperationCount that the maximum number of download operations is managed by the kernel at runtime, so that this value can change dynamically through application usage. I imagine should a download not be possible however, an exception would be thrown, to which you could handle.

On WindowsPhone 8 the maximum limit is 6 active requests at one time from here.

For WindowsPhone 8.1 / UWP you could use the BackgroundDownloader, and let that manage things for you. There is a reported limit of only 5 simultaneous downloads occuring from here.

Despite platform specifics that may limit / open up the simultaneous download connections, I would create your own DownloadManager class that allowed you to keep adding download tasks to, regardless of the current download queue. This manager class would then be able to handle the entire download process for you, including error handling and tracking on specific downloads / kicking off new downloads / notifications of downloads completed / failed.

Within it you could also set your own limits for the amount of simultaneous connections, and base the starting values on what ever values you wanted per platform, of course within OS restrictions.

To be on the safe side, you probably never want to use the maximum number of concurrent downloads available, and use a few less, so speeds are faster and the user experience is better. The better your code handling of scenarios that prevent a download, would allow you to max out the simultaneous download connections as much as possible if you so wish.

Community
  • 1
  • 1
Pete
  • 4,746
  • 2
  • 15
  • 21
  • Thanks for your quick reply. If following your approach, if i create a custom DownloadManager how would i endure bandwidth/download speed is distributed equally among the downloading threads. Will this approach hold good for UWP? Could you please direct me to any msdn documentation, if any such exists. Thanks once again for your kind reply. – Robert Feb 08 '16 at 14:29
  • The fewer threads you have the faster the download will appear. As your dealing with such a few concurrent download threads at any one point, is this really of concern? I don't believe you can set the bandwidth requirements per download thread. – Pete Feb 08 '16 at 14:42