vibe.d beta banner
get vibe.d
0.7.30

Function setTimer

Returns a new armed timer.

Note that timers can only work if an event loop is running.

Prototype

Timer setTimer(
  core.time.Duration timeout,
  void delegate() callback,
  bool periodic = false
);

Parameters

NameDescription
timeout Determines the minimum amount of time that elapses before the timer fires.
callback This delegate will be called when the timer fires
periodic Speficies if the timer fires repeatedly or only once

Returns

Returns a Timer object that can be used to identify and modify the timer.

See also

createTimer

Example

void printTime()
{
	import std.datetime;
	logInfo("The time is: %s", Clock.currTime());
}

void test()
{
	import vibe.core.core;
	// start a periodic timer that prints the time every second
	setTimer(1.seconds, toDelegate(&printTime), true);
}
Authors

Sönke Ludwig

Copyright

© 2012-2016 RejectedSoftware e.K.

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.