title: Run periodic task in background mode on iOS8
body: <p>I want to run a periodic task when my application is in background mode on iOS8. I wrote a following code in swift but failing. Can some point out what is wrong?</p>
  
  <p>Here is my code from AppDelegate.swift</p>
  
  <pre><code>let backgroundQueue = dispatch_get_global_queue(QOS_CLASS_BACKGROUND,0)
  
  func applicationDidEnterBackground(application: UIApplication) {
      println("did enter background")
      dispatch_async(self.backgroundQueue, myBackgroundTask)
  }
  
  func myBackgroundTask() {
      NSThread.sleepForTimeInterval(0.5)
      println("this is back ground task")
      dispatch_async(self.backgroundQueue, myBackgroundTask)
  }
  </code></pre>