Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Abstract class: RT.Util.Threading.Periodic

Summary

Encapsulates a class performing a certain activity periodically, which can be initiated once and then permanently shut down, but not paused/resumed. The class owns its own separate thread, and manages this thread all by itself. The periodic task is executed on this thread.

The chief differences to Timer are as follows. This class will never issue overlapping activities, even if an activity takes much longer than the interval; the interval is between the end of the previous occurrence of the activity and the start of the next. The activity is executed on a foreground thread (by default), and thus will complete once started, unless a catastrophic abort occurs. When shutting down the activity, it's possible to wait until the last occurrence, if any, has completed fully.

Threading: unsafe (call public methods on the creating thread only) - or is it?

Instance methods

bool
Shutdown(bool waitForExit)
  • Virtual
Causes the periodic activity to stop occurring. If called while the activity is being performed, will wait until the activity has completed before returning. Ensures that Periodic.IsRunning is false once this method returns.
void
Start(bool backgroundThread = false)
  • Virtual
Schedules the periodic activity to start occurring. This method may only be called once.

Instance properties

bool Returns false before the first call to Periodic.Start(bool) and after the first call to Periodic.Shutdown(bool); true between them.