Skip to main content

TaskLock

A class in Root.Township, the global namespace.

Runs one async task at a time: Run does nothing if a previous task is still going. Exceptions are logged, not thrown.

Constructors​

MemberWhat it is
TaskLock(bool shouldLogOnCancel)Creates a TaskLock with default values.
TaskLock()Creates a TaskLock with default values.

Fields​

3 private and internal fields
MemberWhat it is
private bool isRunningTrue while a task started by Run is going.
private static Logger LoggerNLog logger for this class.
private bool shouldLogOnCancelIf true, Run logs an error when it skips a task because one is already running.

Methods​

MemberWhat it is
async void Run(Func<Task> task)Starts the task unless one is already running, and logs any exception it throws.

Used in​

Members of other types that take, return or hold a TaskLock: