public sealed class BackgroundTaskOne long operation: an import, a build, a bake.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
⚠ Reporting is safe from any thread and reading is only safe from the UI one. The work runs on a pool thread and the progress bar is read during layout, so a task's numbers would otherwise change halfway through a frame — a status line drawn from a title that was replaced between two reads is the kind of tearing nobody reproduces. So Report queues, and Pump applies the queue once per frame at a point of the shell's choosing.
Cancellation is a token, and it is the reason this exists rather than a Task. Doc 11 asks for "progress with cancellation, never a modal progress dialog" — a modal dialog is what an editor grows when its long operations have no way to be stopped, because stopping them means killing the editor.
Fields and properties (9)
public string TitleWhat it is called.
public string? StatusWhat it is doing right now — a file name, a step — or null.
public float ProgressHow far along it is, from zero to one.
public bool IsIndeterminateWhether it has said how far along it is.
public BackgroundTaskState StateWhere it has got to.
public Exception? FailureWhat it threw, if it threw.
public bool IsCancellationRequestedWhether it has been asked to stop.
public CancellationToken CancellationWhat the work should watch to know it has been asked to stop.
public bool IsRunningWhether it is still going.
Methods (5)
public void Report(float progress, string? status = null)Says how far along it is.
public void Report(string status)Says what it is doing without saying how far along it is.
public void Rename(string title)Renames it.
public void Cancel()Asks it to stop.
public void Dispose()Releases what the cancellation cost.
Used by (7)
- BackgroundTaskManagerVixen.Editor.Ui
- ContentTasksVixen.Editor.App
- EditorShellVixen.Editor.Ui
- EditorShellTestsVixen.Editor.Ui.Tests
- ServiceTestsVixen.Editor.Ui.Tests
- TaskCenterVixen.Editor.Ui
- TaskCenterTestsVixen.Editor.Ui.Tests