First. Thanks for the detailed response. I've filed a bug about the progress reporting ( FB19925898 )
About the other matter, maybe I misunderstood the purpose of BGContinuedProcessingTask, but I think the fact that the user is the one starting the task is important... I don't see it as a way to finish some work in the background that was started in the foreground in a "normal" way, because when the work is started it has to be started from the BGContinuedProcessingTask itself.
The actual work is done by whatever part of the code has to do it, yes, but it is started from within the block of code that is registered when creating the task. I think it makes sense to have a two way communication with the code doing the work so the UI can be updated in whatever way it is necessary...
In my experience, larger work like that generally doesn't "neatly" fit with an individual task architecture, so the natural object to own your BGContinuedProcessingTask is the same object that's managing your tasks in the first place.
In my case I first tried this approach but the object doing the work is an Actor and I couldn't find a way to start a BGContinuedProcessingTask from inside the actor. I had to force the actor to use a specific DispatchQueue but then when the task was active it blocked the actor.
In the end I start the task from outside the actor (in a MainActor class) and then start the work calling an asynchronous function on the actor object.
Thanks again!
Jorge
Topic:
App & System Services
SubTopic:
Processes & Concurrency
Tags: