0

Yesterday, I saw this question about cannot receive data from ORSSerialPort. A solution is to add RunLoop.main.run() right after calling mySerial.SendString(data: "test"). However, this will make the program run forever. If I want the program to immediately terminate after receiving data, how can I do it? Thanks

klg
  • 85
  • 7
  • Does this answer your question? [Multiple workers in Swift Command Line Tool](https://stackoverflow.com/questions/28590701/multiple-workers-in-swift-command-line-tool) – Larme Dec 05 '21 at 10:52
  • I, for instance, used that solution on linked question: https://stackoverflow.com/a/43111274/1801544 to end my script when the download have finished. I have a `func run(completion: (() -> Void))}` async method which is the main method to call, and on the completion I set the boolean value to `true`. – Larme Dec 05 '21 at 10:56
  • could u explain a little more detail? – klg Dec 05 '21 at 14:39
  • Since the linked question is quite forward, What’s your asynchrone code? Do you have a callback? A closure? – Larme Dec 05 '21 at 15:00
  • https://stackoverflow.com/a/43111274/344733 is a good way to do it that is quite close in general to the solution you're already using. – Andrew Madsen Dec 07 '21 at 21:18

0 Answers0