The idea is to prevent HeavyJob from being restarted with every tiny zoom variation, and to only run it once the user has finished zooming.
The goal is to prevent Spinner1_ValueChanged from triggering HeavyJob with every value change, and to only launch the high-resolution rendering after a delay without any new events.
The solution would be to use a Timer as a "debounce".
Each time the value changes, a Timer is restarted. If no new changes occur for X milliseconds, the Timer triggers HeavyJob.
If the user continues to zoom, the Timer is reset, and HeavyJob is never launched unnecessarily.
Add Private DebounceTimer As Timer to Process_Globals
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
DebounceTimer.Initialize("DebounceTimer", 300) ' 300ms delay
DebounceTimer.Enabled = False
Dim jo As JavaObject = Spinner1
Dim e As Object = jo.CreateEventFromUI("javafx.event.EventHandler", "scroll", Null)
jo.RunMethod("setOnScroll", Array(e))
End Sub
Private Sub Spinner1_ValueChanged (Value As Object)
DebounceTimer.Enabled = False '
DebounceTimer.Enabled = True ' restarts the timer
End Sub
Sub DebounceTimer_Tick
DebounceTimer.Enabled = False
HeavyJob
End Sub
Code not tested