title: Is background tasks the solution for this problem?
body: <p>I need to develop an enterprise app that monitors the network traffic. Basically it detects if the user is in wi-fi or cellular data and save the amount of bytes was sent and received in a period of time.
  I saw an App at the AppStore that do exactly this job.
  Detecting wi-fi or cellular data is quite simple using the Reachability Sample provided by Apple.
  My problem is to keep monitoring the bytes sent and received while the app is in background.</p>
  
  <p>As it is an enterprise App, I used UIBackgroundModes "voip" to avoid the app to be terminated.
  I also installed the setKeepAliveTimeout method and I'm able to see the logs each 10 minutes, BUT only for 10 seconds after the method runs. I mean, setKeepAliveTimeout brings my App to run a Timer for 10 seconds each 1o minutes.</p>
  
  <p>I'm thinking wether or not a task in background is the best solution for my problem.</p>
  
  <p>I'll appreciate any comments.</p>
  
  <p>EDIT: Ok guys. Thats the perfect way to do it.</p>
  
  <p>First of all you must read this:
   <a href="http://www.christian-fries.de/blog/files/tag-ios.html" rel="noreferrer">http://www.christian-fries.de/blog/files/tag-ios.html</a></p>
  
  <p>I tried this and it works really fine.
  All we need to do is to create a second thread detached from the main one. This way we have a continuos threading running forever. You must see the GCD docs at Apple's website also.</p>
  
  <p>Second thing you should consider for an enterprise App is to set it up as a voip App, this way iOS will put your App running even after a reboot. It's a special behavior iOS has to keep voip Apps running.</p>
  
  <p>Thats it guys.
  I hope it can help you.</p>