PROP:Timer and moving/resizing the window... 
Author Message
 PROP:Timer and moving/resizing the window...

I've written a Ping app, which i use to monitor if a host is alive or
not. It works nicely, except when i do any moving or resizing with the
window; then, it seems, a EVENT:Timer is generated for EACH PIXEL i
move the window!

This is tiresome, because a ping is sent to a host, based on
EVENT:Timer, which is set to the PingDelay i choose, and the
EVENT:Timer is trying to ping the host 'X pixels' times as fast as
possible...

I Could do a CYCLE on EVENT:Move, but i WANT to be able to move the
window while it's pinging. :)

As an alternative, i've tried the WinAPI SLEEP function, and it
works... in a way... But the whole program sleeps when it's
'sleeping', and nothing happens before it 'wakes up' from that
sleep...

Here is the routine where things happens:

 AppWindow{PROP:Timer} = PingDelay
 Accept
    CASE Field()
      Of ?btnStop
        Case Event()
        Of Event:Accepted
            AppWindow{PROP:StatusText} = 'Idle...'
            Display
            Break
        End !Case Event...
    End !Case Field...
    Trip# += 1
    If Trip# = TimesToPing
        AppWindow{PROP:StatusText} = 'Idle...'
        Display
        Break
    Else
        Do OnePing      ! *** Do the PingStuff once ***
        AppWindow{PROP:StatusText} = 'Waiting ' & Clip(PingDelay) & |
        '/100 sec...'
        Display
!        If Trip# < TimesToPing
!            Sleep(Clip(PingDelay))
!        End !If Trip <...
    End !If Trip# =...
 End !Accept

Here's the bottom line:
I want to be able to move/resize/minimize/maximize the window and be
able to push the STOP button, while it's pinging nicely each
'PingDelay'...

Any suggestions?

Simen Sunde



Fri, 11 Nov 2005 05:46:00 GMT  
 PROP:Timer and moving/resizing the window...
Try this:

of event:openWindow
  loc:refreshStart = clock()

of event:timer
  appWindow{prop:timer} = 0

  if clock() - loc:refreshStart > pingDelay  !---pingDelay should be
hundredths of a second - e.g. 10 seconds = 1000, loc:refreshStart =
    loc:refreshStart = clock()
    do onePing
  end

  window{prop:timer} = 100   !---One second or whatever value you choose up
to 6553

Jim.


Quote:
> I've written a Ping app, which i use to monitor if a host is alive or
> not. It works nicely, except when i do any moving or resizing with the
> window; then, it seems, a EVENT:Timer is generated for EACH PIXEL i
> move the window!

> This is tiresome, because a ping is sent to a host, based on
> EVENT:Timer, which is set to the PingDelay i choose, and the
> EVENT:Timer is trying to ping the host 'X pixels' times as fast as
> possible...

> I Could do a CYCLE on EVENT:Move, but i WANT to be able to move the
> window while it's pinging. :)

> As an alternative, i've tried the WinAPI SLEEP function, and it
> works... in a way... But the whole program sleeps when it's
> 'sleeping', and nothing happens before it 'wakes up' from that
> sleep...

> Here is the routine where things happens:

>  AppWindow{PROP:Timer} = PingDelay
>  Accept
>     CASE Field()
>       Of ?btnStop
>         Case Event()
>         Of Event:Accepted
>             AppWindow{PROP:StatusText} = 'Idle...'
>             Display
>             Break
>         End !Case Event...
>     End !Case Field...
>     Trip# += 1
>     If Trip# = TimesToPing
>         AppWindow{PROP:StatusText} = 'Idle...'
>         Display
>         Break
>     Else
>         Do OnePing ! *** Do the PingStuff once ***
>         AppWindow{PROP:StatusText} = 'Waiting ' & Clip(PingDelay) & |
>         '/100 sec...'
>         Display
> !        If Trip# < TimesToPing
> !            Sleep(Clip(PingDelay))
> !        End !If Trip <...
>     End !If Trip# =...
>  End !Accept

> Here's the bottom line:
> I want to be able to move/resize/minimize/maximize the window and be
> able to push the STOP button, while it's pinging nicely each
> 'PingDelay'...

> Any suggestions?

> Simen Sunde



Fri, 11 Nov 2005 06:39:15 GMT  
 PROP:Timer and moving/resizing the window...
Have you tried what you suggested? ;) It DID pause for 'PingDelay'
milliseconds, but i couldn't even pop up a message('Hello!') inside
'If Clock()...' (?!) And when i moved the window, the delay was
suddenly over... :-o

Clock() is only refreshed approximately every 5.5
hundredths of a second; could this be the problem? Though, it should
work... :-/

I just found this in the helpfile:
        IDLE    Arms a procedure that periodically executes.

But alas; it will only take whole seconds as parameters... But maybe i
can use it... I usually send a ping for each 5 second.... I haven't
tested Idle yet, though; too tired now... :) The time for me here in
Norway is now 01:15, and I'm going to bed... :)

Regards,
Simen Sunde

On Sun, 25 May 2003 18:39:15 -0400, "Jim"

Quote:

>Try this:

>of event:openWindow
>  loc:refreshStart = clock()

>of event:timer
>  appWindow{prop:timer} = 0

>  if clock() - loc:refreshStart > pingDelay  !---pingDelay should be
>hundredths of a second - e.g. 10 seconds = 1000, loc:refreshStart =
>    loc:refreshStart = clock()
>    do onePing
>  end

>  window{prop:timer} = 100   !---One second or whatever value you choose up
>to 6553

>Jim.



>> I've written a Ping app, which i use to monitor if a host is alive or
>> not. It works nicely, except when i do any moving or resizing with the
>> window; then, it seems, a EVENT:Timer is generated for EACH PIXEL i
>> move the window!

>> This is tiresome, because a ping is sent to a host, based on
>> EVENT:Timer, which is set to the PingDelay i choose, and the
>> EVENT:Timer is trying to ping the host 'X pixels' times as fast as
>> possible...

>> I Could do a CYCLE on EVENT:Move, but i WANT to be able to move the
>> window while it's pinging. :)

>> As an alternative, i've tried the WinAPI SLEEP function, and it
>> works... in a way... But the whole program sleeps when it's
>> 'sleeping', and nothing happens before it 'wakes up' from that
>> sleep...

>> Here is the routine where things happens:

>>  AppWindow{PROP:Timer} = PingDelay
>>  Accept
>>     CASE Field()
>>       Of ?btnStop
>>         Case Event()
>>         Of Event:Accepted
>>             AppWindow{PROP:StatusText} = 'Idle...'
>>             Display
>>             Break
>>         End !Case Event...
>>     End !Case Field...
>>     Trip# += 1
>>     If Trip# = TimesToPing
>>         AppWindow{PROP:StatusText} = 'Idle...'
>>         Display
>>         Break
>>     Else
>>         Do OnePing ! *** Do the PingStuff once ***
>>         AppWindow{PROP:StatusText} = 'Waiting ' & Clip(PingDelay) & |
>>         '/100 sec...'
>>         Display
>> !        If Trip# < TimesToPing
>> !            Sleep(Clip(PingDelay))
>> !        End !If Trip <...
>>     End !If Trip# =...
>>  End !Accept

>> Here's the bottom line:
>> I want to be able to move/resize/minimize/maximize the window and be
>> able to push the STOP button, while it's pinging nicely each
>> 'PingDelay'...

>> Any suggestions?

>> Simen Sunde



Fri, 11 Nov 2005 07:15:40 GMT  
 PROP:Timer and moving/resizing the window...
I use that code in an app of mine, it works perfect,  even when I'm moving
and resizing the window.  A message box also works fine inside the if
statement.

What is your onePing routine doing, perhaps that is upsetting things...

You'll need a good nights sleep...  ;)

Jim.


Quote:
> Have you tried what you suggested? ;) It DID pause for 'PingDelay'
> milliseconds, but i couldn't even pop up a message('Hello!') inside
> 'If Clock()...' (?!) And when i moved the window, the delay was
> suddenly over... :-o

> Clock() is only refreshed approximately every 5.5
> hundredths of a second; could this be the problem? Though, it should
> work... :-/

> I just found this in the helpfile:
> IDLE Arms a procedure that periodically executes.

> But alas; it will only take whole seconds as parameters... But maybe i
> can use it... I usually send a ping for each 5 second.... I haven't
> tested Idle yet, though; too tired now... :) The time for me here in
> Norway is now 01:15, and I'm going to bed... :)

> Regards,
> Simen Sunde

> On Sun, 25 May 2003 18:39:15 -0400, "Jim"

> >Try this:

> >of event:openWindow
> >  loc:refreshStart = clock()

> >of event:timer
> >  appWindow{prop:timer} = 0

> >  if clock() - loc:refreshStart > pingDelay  !---pingDelay should be
> >hundredths of a second - e.g. 10 seconds = 1000, loc:refreshStart =
> >    loc:refreshStart = clock()
> >    do onePing
> >  end

> >  window{prop:timer} = 100   !---One second or whatever value you choose
up
> >to 6553

> >Jim.



> >> I've written a Ping app, which i use to monitor if a host is alive or
> >> not. It works nicely, except when i do any moving or resizing with the
> >> window; then, it seems, a EVENT:Timer is generated for EACH PIXEL i
> >> move the window!

> >> This is tiresome, because a ping is sent to a host, based on
> >> EVENT:Timer, which is set to the PingDelay i choose, and the
> >> EVENT:Timer is trying to ping the host 'X pixels' times as fast as
> >> possible...

> >> I Could do a CYCLE on EVENT:Move, but i WANT to be able to move the
> >> window while it's pinging. :)

> >> As an alternative, i've tried the WinAPI SLEEP function, and it
> >> works... in a way... But the whole program sleeps when it's
> >> 'sleeping', and nothing happens before it 'wakes up' from that
> >> sleep...

> >> Here is the routine where things happens:

> >>  AppWindow{PROP:Timer} = PingDelay
> >>  Accept
> >>     CASE Field()
> >>       Of ?btnStop
> >>         Case Event()
> >>         Of Event:Accepted
> >>             AppWindow{PROP:StatusText} = 'Idle...'
> >>             Display
> >>             Break
> >>         End !Case Event...
> >>     End !Case Field...
> >>     Trip# += 1
> >>     If Trip# = TimesToPing
> >>         AppWindow{PROP:StatusText} = 'Idle...'
> >>         Display
> >>         Break
> >>     Else
> >>         Do OnePing ! *** Do the PingStuff once ***
> >>         AppWindow{PROP:StatusText} = 'Waiting ' & Clip(PingDelay) & |
> >>         '/100 sec...'
> >>         Display
> >> !        If Trip# < TimesToPing
> >> !            Sleep(Clip(PingDelay))
> >> !        End !If Trip <...
> >>     End !If Trip# =...
> >>  End !Accept

> >> Here's the bottom line:
> >> I want to be able to move/resize/minimize/maximize the window and be
> >> able to push the STOP button, while it's pinging nicely each
> >> 'PingDelay'...

> >> Any suggestions?

> >> Simen Sunde



Fri, 11 Nov 2005 08:23:28 GMT  
 PROP:Timer and moving/resizing the window...

Quote:
> I've written a Ping app, which i use to monitor if a host is alive or
> not. It works nicely, except when i do any moving or resizing with the
> window; then, it seems, a EVENT:Timer is generated for EACH PIXEL i
> move the window!

Hi Simen,

Make sure that the window where you are running your code does NOT have AUTO
display enabled and that you are not doing any unnecessary DISPLAY
statements.  This can have an awful effect on performance.

Just an idea.

Charles Edmonds

LANSRAD - "Intelligent Solutions for Universal Problems"
www.lansrad.com



Fri, 11 Nov 2005 12:55:04 GMT  
 PROP:Timer and moving/resizing the window...

Quote:
>I've written a Ping app, which i use to monitor if a host is alive or
>not. It works nicely, except when i do any moving or resizing with the
>window; then, it seems, a EVENT:Timer is generated for EACH PIXEL i
>move the window!

<---- Clip --->

After a good nights sleep, i thew myself over the keybord with the
suggestion from Jim swirling in my head... (Big Thanks, Jim! :) )
Here's the result:

 refreshStart# = clock()
 Accept
    CASE Field()
      Of ?btnStop
        Case Event()
        Of Event:Accepted
            AppWindow{PROP:StatusText} = 'Idle...'
            Display
            Break
        End !Case Event...
      End !Of ?btnStop...
    If Trip# = TimesToPing      !*** Are we Finished Pinging? ***
        AppWindow{PROP:StatusText} = 'Idle...'
        Display
        Break
    ElsIf Trip# = 0     !*** Ping the first time. ***
        Do OnePing
    Else
      CASE EVENT()
        of event:timer
          appWindow{prop:timer} = 0
          ElapsedTime# = clock() - refreshStart#
          if ElapsedTime# > pingDelay   !*** Is it Time for a Ping? **
            Temp = ElapsedTime#
            Display(?Temp)  !*** <-- To see elapsed time in window. **
            Do onePing
            ElapsedTime# = 0
            refreshStart# = clock()
          End !If Elapsed...
          appWindow{prop:timer} = 10
        End !Of Event...
      AppWindow{PROP:StatusText} = 'Waiting ' & Clip(PingDelay) |
      & '/100 sec...'
      Display
    End !If Trip#...
 End !Accept

When i move the window now, the time doesn't run away from me like
before. It DOES halt all execution of code while i'm moving the
window, but it continues with the next ping in a timely matter when i
stop 'moving around'... ;)

I can live with that... :-)

Also, Thanks Charles, for reminding me to turn off the AUTO
attribute... I explicit DISPLAY's each control i need to update
anyway, so i don't need Auto... :) (It's a Waste of Time... ;) )

Thanks, All!

Regards,
Simen Sunde



Fri, 11 Nov 2005 16:49:18 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Cannot move or resize a window.

2. Cannot move or resize window.

3. On Windows, don't let the mouse timer interfere with a size/move

4. Help on 'Prop:Timer'

5. Changing PROP:TIMER

6. Q: resizing listbox with window resize

7. VA3.0b - window resizing on form resize

8. Moving buttons on screen resizing

9. Resizing Window in windows

10. C5b: Window formatter resizes window when toolbar is used

11. PROP:Sql or PROP:SqlFilter

12. Help with PROP:WITHNEXT / PROP:WITHPRIOR please

 

 
Powered by phpBB® Forum Software