Enhanced C#
Language of your choice: library documentation
Properties | Public Member Functions | List of all members
Loyc.Utilities.SimpleTimer Class Reference

A fast, simple timer class with a more convenient interface than System.Diagnostics.Stopwatch. Its resolution is typically 10-16 ms on desktop Windows systems. More...


Source file:

Remarks

A fast, simple timer class with a more convenient interface than System.Diagnostics.Stopwatch. Its resolution is typically 10-16 ms on desktop Windows systems.

With SimpleTimer, the timer starts when you construct the object and it is always counting. You can get the elapsed time and restart the timer from zero with a single call to Restart(). The Stopwatch class requires you to make three separate method calls to do the same thing: you have to call ElapsedMilliseconds, then Reset(), then Start().

SimpleTimer cannot be used to measure time periods longer than 24.8 days. The 32-bit millisecond counter will overflow and Millisec will become negative.

Properties

int?? Millisec [get, set]
 The getter returns the number of milliseconds since the timer was started; the resolution of this property depends on the system timer. The setter changes the value of the timer. More...
 
bool Paused [get]
 

Public Member Functions

int Restart ()
 Restarts the timer from zero (unpausing it if it is paused), and returns the number of elapsed milliseconds prior to the reset. More...
 
bool Pause ()
 
bool Resume ()
 
int ClearAfter (int minimumMillisec)
 Restarts the timer from zero if the specified number of milliseconds have passed, and returns the former value of Millisec. More...
 

Member Function Documentation

◆ ClearAfter()

int Loyc.Utilities.SimpleTimer.ClearAfter ( int  minimumMillisec)
inline

Restarts the timer from zero if the specified number of milliseconds have passed, and returns the former value of Millisec.

Returns
If the timer was restarted, this method returns the number of elapsed milliseconds prior to the reset. Returns 0 if the timer was not reset.

If this method resets a paused timer, it remains paused but Millisec is set to zero.

References Loyc.Utilities.SimpleTimer.Millisec.

◆ Restart()

int Loyc.Utilities.SimpleTimer.Restart ( )
inline

Restarts the timer from zero (unpausing it if it is paused), and returns the number of elapsed milliseconds prior to the reset.

References Loyc.Utilities.SimpleTimer.Millisec.

Property Documentation

◆ Millisec

int?? Loyc.Utilities.SimpleTimer.Millisec
getset

The getter returns the number of milliseconds since the timer was started; the resolution of this property depends on the system timer. The setter changes the value of the timer.

Referenced by Loyc.Utilities.SimpleTimer.ClearAfter(), and Loyc.Utilities.SimpleTimer.Restart().