public sealed class BackgroundTaskManagerThe long operations the editor is running, and what they have got to.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Never a modal progress dialog — doc 11 — so this is a list, a status bar and a panel. An import that takes forty seconds must not stop somebody opening a different file while it runs, and an editor whose long operations block it is one where every long operation has to be made short.
⚠ Every mutation lands on the UI thread, in Pump. Work runs wherever the caller put it; what it reports is queued and applied at one point in the frame. This is the whole of the threading design and it is deliberately the smallest one that works: no locks around the task list, no concurrent collection for the UI to walk, and a frame that sees one consistent set of numbers.
⚠ A finished task stays in the list until it is pumped away. Otherwise a task that completes between two frames never appears at all, and an import that failed instantly reports nothing — which reads as an import that silently did nothing.
Fields and properties (3)
public IReadOnlyList<BackgroundTask> TasksWhat is running, oldest first.
public bool IsBusyWhether anything is running.
public float ProgressHow far along everything is together, from zero to one.
Events (2)
public Action<BackgroundTaskManager>? ChangedRaised after Pump applies anything, and when a task starts.
public Action<BackgroundTask>? EndedRaised once per task, after it stops, whatever it stopped as.
Methods (6)
public BackgroundTask Begin(string title)Starts a task the caller drives itself.
public BackgroundTask Start(string title, Func<BackgroundTask, Task> work)Starts a task and runs it.
public void Complete(BackgroundTask task)Says a task the caller was driving has finished.
public void Fail(BackgroundTask task, Exception? failure = null)Says a task the caller was driving has failed.
public void CancelAll()Asks everything running to stop.
public void Pump(int budget = 4096)Applies everything the tasks have reported since the last frame.
Used by (7)
- BackgroundTaskVixen.Editor.Ui
- ContentTasksVixen.Editor.App
- EditorShellVixen.Editor.Ui
- EditorShellTestsVixen.Editor.Ui.Tests
- ServiceTestsVixen.Editor.Ui.Tests
- TaskCenterVixen.Editor.Ui
- TaskCenterTestsVixen.Editor.Ui.Tests