Is it possible to make multiple downloads at a time?
When you send downloadWithDelegate message to NKAssetDownload the Newsstand framework just add it into its queue to download. After that there is no control in developer's hand as to when download starts. As far as I can tell from my experience, it do not start 2 download simultaneously. When one completes it start another one from the queue. I don't know why it is implemented this way but no parallel download.
Related
I wonder what techniques would you use when, say a page contains links to 6 videos, 300Mb each and you want to download them all. Should I write my custom downloader?
I'm used to use MediaPipeline but it utilizes the framework scheduler which has the following issues:
You never know which file is currently being downloaded
You have no idea on download progress/state until it fails
Strange timeout behaviour:
a) Looks like timeout is applied to the whole request download operation, not only to pauses in download. So, say, having a timeout of 5min I will never be able to download a file which takes 6 min to download. b) If you make 5 concurrent long requests and one of them is taking too long, you will get all of them (not complete yet) timed out. You have to limit the number of concurrent requests by 1 in settings (which will affect the whole spider).
You can make use of Youtube downloader after having retrieve links to the videos.
Youtube downloader will try to continue if video has not finished downloading. You can also force it to continue. Write a wrapper around it for concurrency if it takes long for single downloads.
Disclaimer: I am not in anyway affiliated with the maintainers of this package.
I am a bit confused about the different options to handle file downloads on iOS.
I want to be able to handle > 2.000 downloads a time, so some kind of parallelism would be nice
I want a download to be started immediately when fired
I want a download not to be paused or stopped when sending the app to the background
The concrete scenario is a bunch of downloads which are made initially after the user logs into the application. Here I have to download that many files which are mainly small images.
Currently I am using NSURLSessionConfiguration's defaultSessionConfiguration, but going this way the downloads get paused when the user suspends the app (which is likely as the full process needs some minutes).
NSURLSessionConfiguration backgroundSessionConfiguration seems to be the better way to go, but I am seeing delays of up to 20-30 seconds before anything happens after initializing. That's propably okay for some scenarios, but not for mine.
So is there a way to get a workaround to that delay issue? Otherwise I will propably go the "old way" and just download the files in background threads on my own with the 10 minutes limitation.
I wanted to make an http call when my application is running in the background where i am trying to download multiple files. Is it possible to achieve this task. If available can anyone provide me with a sample code.
Thanks in advance.
Once the application is in the background it will usually be suspended. So you will not be able to download data continuously in the background.
If your task is limited you could try implementing beginBackgroundTaskWithExpirationHandler:. This will allow you to ask the system for extra time to perform the remainder of the task in the background.
You can take a look at the documentation provided by Apple to further understand how it is done.
Executing Code in the Background
I am building one application on Mac OS X (10.6). In this application, I have one screen where user will provide input and that will be saved as a plist in local folder. This plist file needs to be trasferred to server using HTTP POST service. There should be check for server connectivity and if connections fails the files will be saved in local folder. With certain time duration, again the server connection will be checked and if found, then send all the files store in local folder one by one.
Basically, The GUI application will run continously to get input from user and in another thread there should be check for server connectivity and sending the files.
So my question is what might be the good approach to solve the problem and if any one can send some sample code, it would be great to me.
Thanks,
Barun
There are several approaches to threading in Objective-C! The easiest strategy is NSOperationQueue. Override NSOperation to handle your HTTP request, optionally set a completion block if you need to be notified when it's done, add an instance of it to an NSOperationQueue object and you're good to go. Set up an NSTimer to reschedule the upload if it fails the first time. You can use NSURLConnection to handle the web stuff. Note that NSURLConnection can make connections asynchronously or blocking. Since your NSOperation subclass runs in a separate thread already, you probably want to use the blocking method (if you don't you have to create a concurrent NSOperation subclass, which is a lot more work).
You can also use Grand Central Dispatch's API, detach a new thread to methods you specify, or use plain old c (I wouldn't recommend the last two but it's good to mention them). As a bonus, NSOperationQueue and Grand Central Dispatch both know "what's right" when you have multiple operations running at once, and will scale the number of threads to fit the number of core's in the user's computer to obtain the best performance.
Check the docs for NSOperationQueue, NSOperation, and NSURLConnection. The guides and example projects will have all the source code you need to get you started in the right direction.
I have a windows mobile application
I have noticed that it properly terminate on exiting, they simply minimize and take up memory. I need to cehck whether any instance of the same application is running in the taskmanager.If exists, i need to kill the process.
I need to write small app that would loop through all open application processes and terminate the required one.
Does such an application exist? If not, which onecould I use to write my own app for it?
Typically this is not how you solve this problem.
You should hold a 'mutex' in your application, and when it launches a second time, you first check this mutex, and if it's taken, you know your app is already running.
Find an appropriate global mutex to hold, and then check for it (I'm not sure what sort you can use on whatever version of Windows Mobile you are targetting, but a trivial search should help you find the answer).
If your app shows an [X] in the corner that's a Minimize button. Change the MinimizeButton property of the form and it will become an [ok] button which will close it.
The CF under Windows Mobile already enforces application singleton behavior. If the app is already running, the CF will look for it, find it, and bring it to the fore for you. No extra work needed.
If you really want to find the process and terminate it, that's done with the toolhelp API set. You can P/Invoke it or use the classes in the Smart Device Framework.