BASIC+Calc | How to run independent sand timer simultaneously

This code runs only sand timer. Can you please help correct in order to run sand timer and stop sand timer ?


[LOCalcBASIC_ProcessBarIndependent_ByNukool.ods|attachment]
LOCalcBASIC_ProcessBarIndependent_ByNukool.ods (14.9 KB)

Do you want to use a separate dialog box for this purpose? Why not use the built-in Status Bar? It seems to me that this is somewhat simpler and more efficient.

    Sub runDemo(Optional oEvent As Variant)
    Dim oDoc As Variant, oSheet As Variant
    Dim statusIndicator As Variant
    Dim i%, j&, iteration&
    	oDoc = ThisComponent
    	oSheet = oDoc.getCurrentController().getActiveSheet()
    	oSheet.clearContents(4)
    REM create StatustatusIndicator for Frame of the current document
        statusIndicator = oDoc.getCurrentController().getFrame().createStatusIndicator()
    	iteration = 0
    REM Set default text and length (scale) of indicator (100%=full count of iterations)
    REM 16 "long steps" + 100 "quick steps" 
        statusIndicator.start("Processing ", 116)
    	For i = 1 To 16
    Rem For "long steps" each iteration
    		iteration = iteration + 1
    		statusIndicator.setValue(iteration)
    		If	i = 10 Then
    			For j = 0 To 10000
    				oSheet.getCellByPosition(1, i - 1).setString(j)
    Rem For "quick steps" no need show each iteration
    				If j Mod 100 = 0 Then 
    					iteration = iteration + 1
    					statusIndicator.setValue(iteration)
    				EndIf
    			Next j
    		EndIf
    		Wait 100
    		oSheet.getCellByPosition(0, i - 1).setString(i)
    	Next i
    	statusIndicator.end()
    End Sub

TimeOfProcess.ods (11.9 KB)

If you still want to use a separate dialog box for this purpose, then you can do it like this
LOCalcBASIC_ProcessBarIndependent_ByNukool_edited.ods (17.2 KB)