title: How to execute a method every second on a background thread so it doesn't affect the performance of the app
body: <p>I am trying to access my database every 30 seconds, however, whenever the method executes I can clearly see a performance dip in the application.</p>
  
  <p>So far this is my current code:</p>
  
  <pre><code>var timer = Timer()
  
  override func viewDidLoad() {
      super.viewDidLoad()
      scheduledTimerWithTimeInterval()
  
  }
  
  func scheduledTimerWithTimeInterval(){
      timer = Timer.scheduledTimer(timeInterval: 30, target: self, selector: #selector(self.updateCounting), userInfo: nil, repeats: true)
  }
  
  @objc func updateCounting(){
      getDatabaseInfo()
  }
  </code></pre>
  
  <p>I am trying to do the same thing, except I would like to execute the getDatabaseInfo() method on a background thread so that the app's performance is not compromised.</p>