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
cancellationToken
CancellationToken?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
disposing
booltrue 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(Action<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(Action<CancellationToken> action)
Parameters
action
Action<CancellationToken>The action to run.
WaitLastActionDone()
Waits for the last action to complete execution.
public void WaitLastActionDone()