The following code does not print ..In Background..
and prints ..Executing..
I know I am missing something really basic. I read up other questions with the same, but they all seems like they are running the same code.
Some possible duplicates that did not help here
I have extracted the exact code in question, I don't think anything more is needed to help debug this.
func execute() {
print("..Executing..")
DispatchQueue.global(qos: .background).async {
self.doInBackground()
DispatchQueue.main.async {
self.doAfterBackgroundCompletes()
}
}
}
func doInBackground() {
print("..In Background..")
EDIT
The below works. But I am wondering shouldn't a http request be in a background thread. Atleast in Android if http request is not in the background thread it causes an issue.
func execute() {
print("..Executing..")
self.doInBackground()
self.doAfterBackgroundCompletes()
// DispatchQueue.global(qos: .background).async {
// DispatchQueue.main.async {
// self.doInBackground()
// self.doAfterBackgroundCompletes()
// }
// }
}