---
title: "CallPeriodically"
canonical: "https://docs.cuesystem.com/space/CVCHELP/510787848/CallPeriodically"
format: markdown
---
> Macro (toc)

---

# _CallPeriodically 

_CallPeriodically invokes the function fncname periodically with a time period between calling. Only function without parameters and return values can be used as a fncname. 

#### Syntax 

```visualbasic
_CallPeriodically(fncname As Function(), period As Time) As Boolean
```

#### Parameters 

fncname  

Name of the invoked function. 

period 

The time period between calling. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It returns True on success or False if an error occurs. 

#### Example 

```visualbasic
Global DeviceClass test 
  Connector GeneralIOConnector 
  Public Event VoltageIsAbove5V As Process(currentvoltage As Double) 
  Private Var VoltageThreshold As Double := 3.0 

  Function ReadInputVoltage() 
    Var currentvoltage As Double := GeneralIOConnector.GetVoltage() 
    If currentvoltage > VoltageThreshold Then 
      RaiseEvent VoltageIsAboveThreshold(currentvoltage)  
    End If 
  End Function

  Function Init() 
    _CallPeriodically(ReadInputVoltage,:30) 
  End Function 
End DeviceClass
```

# _CallDelayed 

_CallDelayed invokes the function fncname after a specified delay. Only function without parameters and return values can be used as a fncname. 

#### Syntax 

```visualbasic
_CallDelayed(fncname As Function(), delay As Time) As Boolean
```

#### Parameters 

fncname 

Name of the invoked function. 

delay 

Time to wait before calls a function. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It returns True on success or False if an error occurs. 

#### Example 

```visualbasic
Function Lamp_Pulse(switchoffdelayed As time) 
  Lamp1.SwitchOn() 
  _CallDelayed(Lamp1.SwitchOff,switchoffdelayed) 
End Function
```

# _StopSchedule 

_StopSchedule cancels invoking fncname which is used either in the _CallPeriodically or in the _CallDelayed. 

#### Syntax 

```visualbasic
_StopSchedule(fncname As Function())
```

#### Parameters 

fncname 

Name of the function which calling needs to be canceled. 

#### Example 

```visualbasic
Global DeviceClass test 
  Connector GeneralIOConnector 
  Public Event VoltageIsAbove5V As Process(currentvoltage As Double) 
  Private Var VoltageThreshold As Double := 3.0 

  Function ReadInputVoltage() 
    Var currentvoltage As Double := GeneralIOConnector.GetVoltage() 
    If currentvoltage > VoltageThreshold Then 
      RaiseEvent VoltageIsAboveThreshold(currentvoltage)  
    End If 
  End Function 

  Function Init() 
    _CallPeriodically(ReadInputVoltage,:30) 
  End Function 

  Public Function StopReadInputVoltage() 
    _StopSchedule(ReadInputVoltage)  
  End Function 
End DeviceClass
```