Periodic interval processing control (start/stop)

Is there a better way to control periodic interval processing?

Also is there a way to terminate the existing WaitUntil?

See attached spreadsheet for demonstration.
Start_Stop_Interval_Processing.ods (12.6 KB)

LibreOffice BASIC not Python etc.

Thanks

REM  *****  BASIC  *****

Sub Start_Stop_Interval_Processing(oEvent As Object)

	oModel = oEvent.Source.getModel()

	If oModel.Label = "Start - Interval Processing" Then
		oModel.Label = "Stop - Interval Processing"
		While oModel.Label = "Stop - Interval Processing"
			Call Interval_Processing()
		WEnd
	Else
'		Is there a way to terminate the existing WaitUntil?
		oModel.Label = "Start - Interval Processing"
	End If

End Sub


Sub Interval_Processing()

	With ThisComponent.Sheets.getByName("Sheet1")
		Cell = .getCellRangeByName("A1")
		Cell.setValue(Cell.getValue + 1)
	End With

	TimeToRun =  Now() + TimeValue("00:00:05")
	If TimeToRun < Now() Then Exit Sub
	WaitUntil TimeToRun	

End Sub

The discussion about timer There is no timer service. Why? - #13 by Lupp

And if you want to terminate some loop, you can add the condition with global variable to this loop (if gExit then exit sub), and show for example the dialog with the button ‘Cancel’ that will modify the terminated global variable gExit.

Would be nice if Wait() and WaitUntil() had an optional terminate flag parameter. A Boolean var to watch and terminate if true.
Sometimes breaking out of a Wait() / Waituntil() is desirable.