# Poco::Util

# class TimerTask

Library: Util
Package: Timer
Header: Poco/Util/TimerTask.h

## Description

A task that can be scheduled for one-time or repeated execution by a Timer.

This is an abstract class. Subclasses must override the run() member function to implement the actual task logic.

## Inheritance

Direct Base Classes: Poco::RefCountedObject, Poco::Runnable

All Base Classes: Poco::RefCountedObject, Poco::Runnable

Known Derived Classes: TimerTaskAdapter, TimerFunc

## Member Summary

Member Functions: cancel, isCancelled, lastExecution, operator =, updateLastExecution

Inherited Functions: duplicate, referenceCount, release, run

## Types Aliases

### Ptr

using Ptr = Poco::AutoPtr < TimerTask >;

## Constructors

### TimerTask

TimerTask();

Creates the TimerTask.

### TimerTask

TimerTask(
const TimerTask & param576
) = delete;

## Destructor

### ~TimerTask

~TimerTask() override;

Destroys the TimerTask.

## Member Functions

### cancel

void cancel();

Cancels the execution of the timer. If the task has been scheduled for one-time execution and has not yet run, or has not yet been scheduled, it will never run. If the task has been scheduled for repeated execution, it will never run again. If the task is running when this call occurs, the task will run to completion, but will never run again.

Warning: A TimerTask that has been cancelled must not be scheduled again. An attempt to do so results in a Poco::Util::IllegalStateException being thrown.

### isCancelled

bool isCancelled() const;

Returns true iff the TimerTask has been cancelled by a call to cancel().

### lastExecution

Poco::Timestamp lastExecution() const;

Returns the time of the last execution of the timer task.

Returns 0 if the timer has never been executed.

### operator =

TimerTask & operator = (
const TimerTask & param577
) = delete;

### updateLastExecution

void updateLastExecution();

Updates the last execution of the timer task.