Class LooseRunner
Provides a mechanism for running actions asynchronously in a loose manner. Only the most recent action is executed and previous pending actions are discarded.
public class LooseRunner : IDisposable
- Inheritance
-
LooseRunner
- Implements
- Inherited Members
- Extension Methods
Constructors
LooseRunner(CancellationToken?)
Initializes a new instance of the LooseRunner class.
public LooseRunner(CancellationToken? cancellationToken = null)
Parameters
cancellationTokenCancellationToken?Optional cancellation token to control the lifetime of the runner. If not provided, a new token will be created.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by the LooseRunner and optionally releases the managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposingbooltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
GetLastWaiting()
Asynchronously waits for the last action to complete execution.
public Task GetLastWaiting()
Returns
- Task
A task representing the asynchronous wait operation.
TryRun(MergedCancellationTokenRun, CancellationToken?)
Tries to run the specified action asynchronously. If an action is already pending, it will be replaced with the new action.
public void TryRun(LooseRunner.MergedCancellationTokenRun action, CancellationToken? cancellationToken = null)
Parameters
actionLooseRunner.MergedCancellationTokenRunThe action to run. The input cancellation token is the merge of
cancellationTokenand the runner hosted cancellation token that called on disposing.cancellationTokenCancellationToken?external cancellation token
WaitLastActionDone()
Waits for the last action to complete execution.
public void WaitLastActionDone()