title: Swift Cancel DispatchQueue Process
body: <p>I have a UDP method that waits for a reply using the DispatchQueue using the following code:</p>
  
  <pre><code>DispatchQueue.global(qos: .userInitiated).async {
      let server:UDPServer=UDPServer(address:"0.0.0.0", port:5005)
      let (data,_,_) = server.recv(1024)
      DispatchQueue.main.async {
         ...
      }
  }
  </code></pre>
  
  <p>This works perfectly and sets off a process to wait for my data to come in. What's keeping me up at night is what happens if we never get a reply? server.recv never returns so I cannot see how the process will ever end? Is there a way of giving it a predetermined amount of time to run for?</p>