Timer Manual

内容表

关于

A timer can be used to execute a certain function periodically.

TimerInterface

A new timer instance is created with these static functions:

The created timer instance is controlled with these functions:

These observables are called on certain events:

  • ObservableTimerStarted: Notifies the observers that the timer has started.
  • ObservableTimerFinished: Notifies the observers that the timer has finished.
  • ObservableTimerOverload: Notifies the observers that the timer job took longer than the specified interval.
// This example creates a new timer that is executed every second. // After ten executions, the timer stops itself. // g_timer is just a maxon::TimerRef instance.
auto TimerFunction = []() { DiagnosticOutput ( "Timer Tick..." );
if (g_count < 10) { ++g_count; } else { // timer should end g_timer.Cancel(); } }; g_timer = maxon::TimerInterface::AddPeriodicTimer ( maxon::Seconds (1), TimerFunction, maxon::JOBQUEUE_CURRENT ) iferr_return ;

延伸阅读

maxon::JOBQUEUE_CURRENT
static const JobQueueInterface::Current JOBQUEUE_CURRENT
Equivalent to calling GetDestinationQueue(), you just save a function call.
定义: jobqueue.h:361
maxon::Seconds
Timer value in seconds.
定义: timevalue.h:425
iferr_return
#define iferr_return
定义: resultbase.h:1434
DiagnosticOutput
#define DiagnosticOutput(formatString,...)
定义: debugdiagnostics.h:166
maxon::TimerInterface::AddPeriodicTimer
static MAXON_FUNCTION Result< TimerRef > AddPeriodicTimer(TimeValue interval, FN &&job, JobQueueInterface *queue)

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1