pub struct BackgroundTask { /* private fields */ }Expand description
A BackgroundTask does not actually execute any code, only act as a handler, primarily to query
the status of the task, and to cancel the task.
If you are looking to execute code in the background, consider using rusts threading API, or if you
want the core to execute the task on a worker thread, instead use the crate::worker_thread API.
NOTE: If you do not call BackgroundTask::finish or BackgroundTask::cancel, the task will
persist even after it has been dropped, use OwnedBackgroundTaskGuard to ensure the task is
finished, see BackgroundTask::enter for usage.
Implementations§
Source§impl BackgroundTask
impl BackgroundTask
pub fn new(initial_text: &str, can_cancel: bool) -> Ref<Self>
Sourcepub fn enter(&self) -> OwnedBackgroundTaskGuard
pub fn enter(&self) -> OwnedBackgroundTaskGuard
Creates a OwnedBackgroundTaskGuard that is responsible for finishing the background task
once dropped. Because the status of a task does not dictate the underlying objects’ lifetime,
this can be safely done without requiring exclusive ownership.