Re: [swift-users] DispatchQueue.async within infinite loop

2017-10-04 Thread Jeremy W. Sherman via swift-users
Something has to drain blocks sent to the main queue. You can run a Foundation run loop. That should drain the main queue. I believe it also ensures blocks sent to the main queue always run on the main thread. Dispatch includes its own lower-level function to pump the main queue:

Re: [swift-users] DispatchQueue.async within infinite loop

2017-10-04 Thread Rahul Ranjan via swift-users
Hi Geordie, I am new here and so pardon me if I misunderstood anything. When you run a program in Swift, it already runs on main thread by default and then you can all Dispatch async. So for example, while true { // This while loop will run for infinite on main thread Dispatch.main.async {} //