I am trying to figure out what thread or run loop I am on when in an async task. How can I get the thread or run loop from a task?
Task {
do {
print("line: ", #line, Thread.current)
let image = try await self.fetchImage()
print("line: ", #line, Thread.current)
} catch {
let fetch: FetchError = error as! FetchError
print("line: ", #line, Thread.current)
}
print("line: ", #line, Thread.current)
}
print("line: ", #line)
When I try my typical method, I get:
// Class property 'current' is unavailable from asynchronous contexts; Thread.current cannot be used from async contexts.; this is an error in Swift 6.
It still runs, but the warning makes me believe I can't trust the result.