Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MOD is not correct
Message
From
25/07/2015 03:35:02
 
 
To
24/07/2015 20:00:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01622479
Message ID:
01622500
Views:
66
>>>>and I want the WAIT WINDOW to NOT flicker !!! But it does. That is why I added the check for the MOD, so that the WAIT WINDOW would only be updated every 1 second....but it appears that the MOD is wrong and is true for more than each second.
>>>>
>>>>So, is my MOD wrong? IF so, than what should I do to make it only update the WAIT WINDOW each second?
>>
>>>Your DO loop runs at full speed for 5 minutes, which is unnecessary CPU usage even on a multi-core processor. If you do that without DOEVENTS, that can make it hard to switch away from the VFP app, making it seem like the entire computer is unresponsive (as you've probably discovered already).
>>>
>>>I'd be inclined to use the Win32API Sleep function for this: http://news2news.com/vfp/index.php?group=-1&function=80
>>>
>>>Within the main loop, call =Sleep( 1000 ) which will sleep for 1000 milliseconds (1 second). Then WAIT CLEAR, then update with a new WAIT WINDOW. No need for any seconds calculations within the loop. Also, you'll see CPU usage is much less. You may not even need DOEVENTS any longer, but if it turns out you do you're only calling it once per second instead of probably thousands of times per second.
>>
>>Workable, but why ? Wait Window Timeout xxx should be enough and minimize CPU the same way...
>
>Thanks for the reminder ;) I never use the TIMEOUT clause of WAIT WINDOW. That should be perfect for this case.
>
>When I use the Sleep() function in a loop I'm usually doing lots of other things but that never includes WAIT WINDOW, I'm usually updating control(s) instead.

Well, the OP was confusing to me:
the code part reads as if the smallest lag after the file pops into existance is wanted, even if taxing the CPU, but not following the Windows-EventBinding examples, which the seconds()-approach will satisfy or just adding a display start timer also based on datetime(), checking in the existing code for difference >1 and resetting this display start timer .

But the accompanying text was ***all*** about the flickering wait window, which will be cured by all versions offered in the subtree starting with yout post, but with a median lag of 0.5 seconds in exchange for easy to read code.

Sprinkle in the curious llExitLoop2 which is checked by loop control but never changed inside the loop was enough for me to refrain from trying to guess at the most pressing intent ;-)
Previous
Reply
Map
View

Click here to load this message in the networking platform