Skip to content

Instantly share code, notes, and snippets.

@tokizuoh
Last active May 20, 2024 06:40
Show Gist options
  • Save tokizuoh/e7bce4de01959ae88e31f382a70f1743 to your computer and use it in GitHub Desktop.
Save tokizuoh/e7bce4de01959ae88e31f382a70f1743 to your computer and use it in GitHub Desktop.
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Task.detached {
await self.heavyCall()
}
}
func heavyCall() async {
var count = 0
while count < 1_000_000_000 {
count += 1
await Task.yield()
}
print(Thread.isMainThread) // true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment