If WaitServer
Wait 100 Milliseconds
MessageRequester("Continue", "Program will continue...")
WaitServer=0
EndIf
The problem is, I have many gadgets that need to be refreshed to show new data, and if I use Delay() or ElapsedMilliseocnds(), everything gets reezed until the wait-time is finished. So, how do I achieve this? I want that a function waits for the specified time without disturbing other stuff.
If WaitServer
for i = 0 to 100
delay(1)
WindowEvent() ;This allows gadgets to be refreshed etc.
next
MessageRequester("Continue", "Program will continue...")
WaitServer=0
EndIf
Alternatively, perhaps use a thread, or a Windows timer is very easy to set up.
I may look like a mule, but I'm not a complete ass.
Of course, you will not get an exact time of delay with this method. Mind you, the same is true with a Window's timer as that depends very much upon an application's use of the message queue etc.
I may look like a mule, but I'm not a complete ass.
If WaitServer
for i = 0 to 100
delay(1)
WindowEvent() ;This allows gadgets to be refreshed etc.
next
MessageRequester("Continue", "Program will continue...")
WaitServer=0
EndIf
Alternatively, perhaps use a thread, or a Windows timer is very easy to set up.
This is really not the way to do it. :p
Here is an example of a repeating call to a procedure:
Yes, I was just giving the general idea of how to refresh gadgets whilst forcing a delay. I take your point though; use of the ElapsedMilliseconds() command is a good idea.
I may look like a mule, but I'm not a complete ass.
... everything gets reezed until the wait-time is finished. So, how do I achieve this? I want that a function waits for the specified time without disturbing other stuff....
Repeat
If ElapsedMilliseconds() > StartTime + RepeatTime
Echo("I am being repeated every second")
StartTime.l = ElapsedMilliseconds()
EndIf
Delay(1)
ForEver
This makes the appl. itself wait till the loop finished if its not performed in a thread and as I understood right he wants the timer to be processed in Backgr. so his gadgets ca be refreshed fast etc.
In case of a timer best would be a callback approach like included in the winAPI: http://msdn.microsoft.com/library/defau ... tevent.asp
This is a multimediatimer (others are available also) and could easely used also for other stuff.
I do use it for proper FPS playback of moviecontend where frames are received via the avifil32 functions.
Just set the delay in ms, the timerProc callback wich calls your intervalled routine and let it go.
Repeat
If ElapsedMilliseconds() > StartTime + RepeatTime
Echo("I am being repeated every second")
StartTime.l = ElapsedMilliseconds()
EndIf
Delay(1)
ForEver
This makes the appl. itself wait till the loop finished if its not performed in a thread
The loop here is for demonstration only purposes, if you need to use this example put this code:
Global #timerquit
Procedure Timer1(time) ;time is in milliseconds
Delay(time)
Repeat
;YOUR REPEATED CODE
Until #timerquit=1
EndProcedure
;fire the timer every second:
CreateThread(@timer1(),1000)
Global #timerquit
Procedure Timer1(time) ;time is in milliseconds
Delay(time)
Repeat
;YOUR REPEATED CODE
Until #timerquit=1
EndProcedure
;fire the timer every second:
CreateThread(@timer1(),1000)
Thanks thefool! I knew that I have to do a thread, but if I remember right, last week I tried it but failed. Thanks for the working example!
Global #timerquit
Procedure Timer1(time) ;time is in milliseconds
Delay(time)
Repeat
;YOUR REPEATED CODE
Until #timerquit=1
EndProcedure
;fire the timer every second:
CreateThread(@timer1(),1000)
Thanks thefool! I knew that I have to do a thread, but if I remember right, last week I tried it but failed. Thanks for the working example!
Global timerquit
Procedure Timer1(time) ;time is in milliseconds
Repeat
Delay(time)
Debug 1
Until timerquit=1
EndProcedure
;fire the timer every second:
CreateThread(@timer1(),1000)
Repeat
ForEver
I may look like a mule, but I'm not a complete ass.