3using System.Threading.Tasks;
25 public string?
Stage {
get;
set; }
60 public Task<bool>
Wait(CancellationToken cancellationToken)
63 throw new InvalidOperationException(
"Job not started!");
65 return task.WaitAsync(cancellationToken);
81 throw new InvalidOperationException(
"Job already started");
Class for pairing Tasks with CancellationTokenSources.
int? Progress
The progress of the job.
void Cancel()
Cancels task.
Task< bool >? task
The Task being run.
readonly Func< CancellationToken, Task< bool > > jobActivator
A Func<T, TResult> taking a CancellationToken and returning a Task<TResult> that the JobHandler will ...
Task< bool > Wait(CancellationToken cancellationToken)
Wait for task to complete.
bool Started
If the job has started.
void Start()
Starts the job.
readonly CancellationTokenSource cancellationTokenSource
The CancellationTokenSource for task.
JobHandler(Func< CancellationToken, Task< bool > > jobActivator)
Initializes a new instance of the JobHandler class.
string? Stage
The stage of the job.