Hi
My First question here.
I need further clarity on using detached Task. I need to process data that could be quite time consuming and I dont want to do it on the main thread. I see a lot of post suggesting that one should keep away from detached tasks, but if you dont want to occupy the main thread I dont see an alternative. So here is a simplified version of my code.
Is this safe? It does not produce any warnings:
struct Detach{
var test = 0
//: –—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–—–— ://
mutating func testing()async{
let detached = Task.detached(priority: .background) {
// could be a very long processing algorithm
return 50
}
test = await detached.value
}
}
thanks