Re: Sleep API function

Tech-Archive recommends: Speed Up your PC by fixing your registry



"Sam Hobbs" <samuel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:uPkzFWboFHA.3912@xxxxxxxxxxxxxxxxxxxx
> "Bob Butler" <tiredofit@xxxxxxxxxx> wrote in message
> news:uDzZZ7aoFHA.568@xxxxxxxxxxxxxxxxxxxxxxx
>>
>> good point; i'm using windows 2000 SP4 and VB6 SP5
>
> Okay, well 2000 should be more responive than 95/98/ME and such. You
> probably know that. So that possibility is eliminated.
>
>> but it is unrelated
>
> It depends on how "related" is defined. They are related to the
> extent that the OS is scheduling and switching and such.
>
> Note that the Sleep documentatin says "You have to be careful when
> using Sleep ....".

I haven't seen the doc for a while and don't have it availabel to check but
IIRC the warnings are mainly because it makes the app that is calling it
unresponsive. I don't ever recall seeing a warning about it making other
applications unresponsive!

> Which is enough for me to expect unexpected
> behavior such as what you describe. Of course, you are asking if
> anyone else has actually had this type of thing happen. I am just
> saying that you seem to think it is not normal, but it might be nore
> normal than you realize.

I'm sure it's been happening all along so if that makes it "normal" then you
are right. OTOH I can't think of any reason why searching for files from
windows explorer should be affected in any way by another app sitting in a
Sleep state.

>> I've used ALT-TAB or clicked a taskbar icon to switch
>> to explorer while the VB app runs in the background. This came up
>> from other scenarios where the actual delay was being done in an app
>> started by SMS without the user's knowledge and there is no
>> relationship between the real app and the user's tasks except that
>> Explorer hangs starting a search.
>> I left that out because I was able to duplicate it so easily in the
>> VB IDE.
>
> Sorry, I don't understand all that. Is Sleep relevant there or do you
> not know if it is? Are you saying that you are experiencing a delay
> and you are attempting to determine the cause?

I'm saying that while my VB app is waiting for a Sleep period to end windows
explorer also seems to wait when starting a search. As far as I can tell
they appear to be related but I can't fathom why.

>> [pet peeve]BTW, it's 'effect', not 'affect', unless you are saying
>> this is just an affectation of explorer (which I'm beginning to
>> believe) <g>[/petpeeve]
>
> I understand about pet peeves, such as use of "may", as in "they may
> do it". In junior high school, I used either "effect" or "affect" in
> a paper and the teacher commented. I explained why I used the word I
> used and that was that; I think the teacher did not originally
> understand what I meant. I am not an expert, and you might be right.
> The word "affect" still seems correct to me, but you could be
> correct. I think I meant that Sleep affects the system. The effect is
> that the system is less responsive.

Just that Sleep in one app doesn't normally affect other apps (the system)
but does appear to affect this one thing and that strikes me as unusual and
worth understanding better.

> I think VB programmers are more likely to use Sleep, but C/C++
> programmers also use Sleep. See my "Using Waitable Timers" for a
> simple sample alternative to use of Sleep(). It is written using C++
> but I am nearly certain I have seen similar versions using VB.

Yes, I know of other methods and will probably switch to one. In this case
it was a background app that I didn't care would show as 'not responding'
now and then so I didn't feel it worth the effort to use an alternate
approach. If I can confirm that Sleep has this effect on windows explorer
(and by extension possibly on other apps) then I may just abandon Sleep
completely. I'm just lookign for some feedback to see if others have seen
this and if anybody knows what the conenction is.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."

.



Relevant Pages

  • Re: iPhone being exposed on Watchdog!
    ... then the app gets terminated. ... Do people really leave applications running when they sleep their ... so full of outrage. ... We need to be angry, but now we're less likely to ...
    (uk.comp.sys.mac)
  • Re: processor time allocation
    ... When an app is doing IO it does NOT show up in the task manager as process ... simply stating that my process is not getting cpu time really doesn't give ... > perfectly fine using Sleep to obtain a near 20 Hz frequency. ... > Which is that my App is CPU starved and windows wont give my app more than ...
    (microsoft.public.vc.mfc)
  • Re: Notification of WIndows Shutdown.
    ... other application is done (checks a registry entry) then it does its ... If you are coming out of a Sleep API call and then immediately ... I think Bob is spot on here. ... Your app does not shut down because the form gets ...
    (microsoft.public.vb.general.discussion)
  • Re: Sleep API function
    ... Note that the Sleep documentatin says "You have to be careful when using ... > to explorer while the VB app runs in the background. ... > just an affectation of explorer ...
    (microsoft.public.vb.winapi)
  • Re: Timing your loops
    ... Instead of taking a 'greedy' approach that uses up as much CPU time as possible unless you remember to stop it, have you considered an approach whereby you generally do nothing, but occasionally you'll render a frame? ... Providing your timer-handling code takes less than 30ms to execute, your app should go back to sleep between frames. ... After all they are running and while doing nothing are allocated all the cpu power left....mustn't be left for a rainy day after all. ...
    (microsoft.public.win32.programmer.directx.managed)