Vixen
02b45cc4
csharp
public sealed class BackgroundTask

One 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 Title

    What it is called.

  • public string? Status

    What it is doing right now — a file name, a step — or null.

  • public float Progress

    How far along it is, from zero to one.

  • public bool IsIndeterminate

    Whether it has said how far along it is.

  • public BackgroundTaskState State

    Where it has got to.

  • public Exception? Failure

    What it threw, if it threw.

  • public bool IsCancellationRequested

    Whether it has been asked to stop.

  • public CancellationToken Cancellation

    What the work should watch to know it has been asked to stop.

  • public bool IsRunning

    Whether 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