title: How do I dispatch_sync, dispatch_async, dispatch_after, etc in Swift 3, Swift 4, and beyond?
body: <p>I have lots of code in Swift 2.x (or even 1.x) projects that looks like this:</p>
  
  <pre><code>// Move to a background thread to do some long running work
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
      let image = self.loadOrGenerateAnImage()
      // Bounce back to the main thread to update the UI
      dispatch_async(dispatch_get_main_queue()) {
          self.imageView.image = image
      }
  }
  </code></pre>
  
  <p>Or stuff like this to delay execution:</p>
  
  <pre><code>dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(0.5 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) {
      print("test")
  }
  </code></pre>
  
  <p>Or any of all kinds of other uses of the Grand Central Dispatch API...</p>
  
  <p>Now that I've opened my project in Xcode 8 (beta) for Swift 3, I get all kinds of errors. Some of them offer to fix my code, but not all of the fixes produce working code. What do I do about this?</p>