Hey guys. (problem stated after code bit..)
I'm trying to do a simple program, where you can enter a given number of minutes in a field. It will then remind you when that time is up. If you enter 1, it will remind you after 1 minute. Code:
I'll facelift the program, when the code is okay. Here's my problem. While the time is running, I get 100% CPU usage. Isn't that a bit much? Is there some other way to do this, without that much CPU load?
I'm trying to do a simple program, where you can enter a given number of minutes in a field. It will then remind you when that time is up. If you enter 1, it will remind you after 1 minute. Code:
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 counter=0 Global target=0 Global MilTemp=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=Int(TextFieldText(MinField))*60 MilTemp=MilliSecs() Repeat If MilTemp<=(MilliSecs()-1000) Then MilTemp=MilliSecs() If counter=0 Then counter=1 Else counter=counter+1 End If If counter=target Then Notify "Time is up!" : Exit End If Until KeyHit(1) End Function
I'll facelift the program, when the code is okay. Here's my problem. While the time is running, I get 100% CPU usage. Isn't that a bit much? Is there some other way to do this, without that much CPU load?