Interface ITaskRunner
Represents a task runner that executes tasks while managing busy state and ensuring that exceptions propagate to the UI thread.
Inherited Members
Namespace: Singulink.UI.Tasks
Assembly: Singulink.UI.Tasks.dll
Syntax
public interface ITaskRunner : INotifyPropertyChanged
Remarks
Instances are fully thread-safe and all methods can be safely called from any thread.
Properties
| Name | Description |
|---|---|
| HasThreadAccess | Gets a value indicating whether the current thread is the UI thread associated with this task runner. |
| IsBusy | Gets a value indicating whether the task runner is currently executing busy tasks. Bindings to this property can be used to control UI state when busy tasks are running, such as disabling input or showing a loading spinner. |
Methods
| Name | Description |
|---|---|
| Post(Action) | Asynchronously posts the specified action to the UI thread for execution. Tracked as a non-busy task. |
| RunAndForget(Func<Task>) | Runs the specified task and propagates any exceptions to the UI thread. |
| RunAndForget(Task) | Runs the specified task and propagates any exceptions to the UI thread. |
| RunAsBusyAndForget(Func<Task>) | Runs the specified task as a busy task and propagates any exceptions to the UI thread. |
| RunAsBusyAndForget(Task) | Runs the specified task as a busy task and propagates any exceptions to the UI thread. |
| RunAsBusyAsync(Func<Task>) | Runs the specified task as a busy task. |
| RunAsBusyAsync(Task) | Runs the specified task as a busy task. |
| RunAsBusyAsync<T>(Func<Task<T>>) | Runs the specified task as a busy task. |
| RunAsBusyAsync<T>(Task<T>) | Runs the specified task as a busy task. |
| SendAsync(Action) | Synchronously executes the specified action if the current thread is the UI thread, otherwise asynchronously posts it to the UI thread for execution and returns a task that completes when execution finishes. Tracked as a non-busy task. |
| SendAsync(Func<Task>) | Synchronously executes the specified function if the current thread is the UI thread, otherwise asynchronously posts it to the UI thread for execution, and then returns a task that completes when the execution of the task returned by the function completes. Tracked as a non-busy task. |
| SendAsync<TResult>(Func<Task<TResult>>) | Synchronously executes the specified function if the current thread is the UI thread, otherwise asynchronously posts it to the UI thread for execution, and then returns a task that contains the result of the task returned by the function when it completes. Tracked as a non-busy task. |
| SendAsync<TResult>(Func<TResult>) | Synchronously executes the specified function if the current thread is the UI thread, otherwise asynchronously posts it to the UI thread for execution and returns a task that contains the result when execution finishes. Tracked as a non-busy task. |
| SendAsync<T>(T, Action<T>) | Synchronously executes the specified action if the current thread is the UI thread, otherwise asynchronously posts it to the UI thread for execution and returns a task that completes when execution finishes. Tracked as a non-busy task. |
| SendAsync<T, TResult>(T, Func<T, TResult>) | Synchronously executes the specified function using the provided state if the current thread is the UI thread, otherwise asynchronously posts them to the UI thread for execution and returns a task that contains the result of the function when execution finishes. Tracked as a non-busy task. |
| WaitForIdleAsync(bool) | Waits for all busy tasks to complete, optionally also waiting for non-busy tasks (and posted/sent messages). |