Thank you to all of you! ;) Here is a slightly changed code, which works:
As you can see, I pre-calculated the target-MilliSecs() number, and then just keep checking to see if it equals this, or if it's bigger than this. The Delay command ensures low CPU usage. Without the Delay thing, it uses 100% CPU consumption.
BUT.. A few seconds after I pressed Go!, the "Running" status in Win Task Manager, changes to "Not Responding". But it still works, and it's very precise (150 millisecs off, is okay..). How come, it's "Not Responding"..?
MainWindow=CreateWindow ("Reminder",GraphicsWidth()/2-100,GraphicsHeight()/2-75,200,150,0,5) Global MinField=CreateTextField (10,25,160,20,MainWindow) Global GoButton=CreateButton ("Go !",10,55,60,20,MainWindow) Global target=0 Global mins=0 Repeat eid=WaitEvent() Select eid Case $803 Exit End Select If EventSource()=GoButton If EventID()=$401 Go() End If End If Forever Function Go() target=MilliSecs()+((Int(TextFieldText(MinField))*60)*1000) Repeat If MilliSecs()>=target Then Notify "Time is up!":Return Delay 150 Forever End Function
As you can see, I pre-calculated the target-MilliSecs() number, and then just keep checking to see if it equals this, or if it's bigger than this. The Delay command ensures low CPU usage. Without the Delay thing, it uses 100% CPU consumption.
BUT.. A few seconds after I pressed Go!, the "Running" status in Win Task Manager, changes to "Not Responding". But it still works, and it's very precise (150 millisecs off, is okay..). How come, it's "Not Responding"..?