If you haven't disabled ApplisationIdleDetection, your process is stopped while entering Lock screen - thus you probably get the exception - like I've said in comment. Disabling will solve this issue, but you must be aware of few things:
- you will still get the exception when hitting Start Button (or other case putting your app to dormant state). In this case your app is stopped and there is no way to prevent this behaviour.
- you must fulfill certification requirements when disabling App Idle Detection - point 6.3
- if you want to download files in the Background (lock screen, after closing/leaving app) then you can think of Background Transfers