Re: Re-entrancy???

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Cute :) It was actually Eduardo who claimed it was 1 ms, then after he
either tested it or read the documentation he came back and admitted it
was 16 ms. so seems the person you are saying was right, clearly did not
know about the need to change the timer interval. As none of them stated
this *requirement* I thin it is indeed very safe to assume they didn't
know, especially given their responses when challenged on the matter.

I already told you, for the case, 1 ms or 16 ms make not a big difference.
Wake up, you are running it on Windows.
Unless you use the timeXXXPeriod APIs as some have pointed.


No my comments were pretty clear (at least I thought <g>) I said for the
code that the OP posted which appears to be polling a PLC and does so at
intervals controlled by Timer event, there is absolutely no reason to add
extra sleep calls in that code.
If that is still unclear to you, I suggest you look at the code the OP
posted.

I believe that you are deliberately trying to confuse things.

As i pointed already once and you ignored it, the OP had the problem that
the one second timer was firing again when the PLC still didn't respond to
the previous event of one second earlier. So, at least sometimes, it runs
continuosly in the loop. How often? I don't know, but may be often. So it is
almost like a continuous loop.

My final words are:

When i read the OP first message, i just assumed it was logging some data to
a database or monitoring a process in the PC monitor, or something like
that.
I really didn't think that he was doing a critical process in real time. And
i still
think it must be the first option, the OP never said that he was managing a
robotic machine in real time from the PC.
It was in fact you that started with the idea that the OP was controlling a
process in real time there.

The OP wasn't against the use of Sleep, but he undestood that using Sleep
means to remove Doevents. (Well, in my first message in the thread i said to
remove Doevents, but just to point where the problem was [the timer was
firing again when the last one was still processing] and to use Sleep but
not as a replacement for Doevents. I wanted to answer quiecky because i
had to do other things and i didn't had the time to explain the whole thing
at
that moment).

So, if he is just logging data or monitoring, he can safely place a Sleep
100 (well, we would have to see how much data he is receiving and the input
buffer size, but at least Sleep 1 is safe surely). Then the CPU runs
quietly.

If he is really controling a process in real time, then i would strongly
suggest not to do it in Windows.

I don't see the need of any closed-Doevents-loops-without-Sleep in none of
the two
cases.


.



Relevant Pages

  • Re: Re-entrancy???
    ... DoEvents statements. ... then adding Sleep is detrimental to the program. ... If you are comunicating _two or more_ devices in real time, ... In Windows you can't response in real time even if you want, ...
    (microsoft.public.vb.general.discussion)
  • Re: Re-entrancy???
    ... the one second timer was firing again when the PLC still didn't respond to ... You didn't know that DoEvents yielded to other app (same as sleep 0), and argued repeatedly that it didn't ... All your presumptions have been based on you clearly not knowing what DoEvents does, clearly you not knowing that Sleep 1 will default to the minimum timer resolution, and clearly not reading what the OP posted. ... The point is there's no need to add delays *without* reason. ...
    (microsoft.public.vb.general.discussion)
  • Re: Clearing the Mouse Buffer, if there is such a thing ;-)
    ... Using Sleep with any time period doesn't work (I was trying to avoid the ... Sleep 100 plus DoEvents won't. ... Of course, I'm sure the timer would have worked, too. ... That avoids the extra delays that sleep and doevents will ...
    (microsoft.public.vb.general.discussion)
  • Re: Sticky Shutdown
    ... Sleep what actually does, is to freeze your program execution, so if you ... What does allow to do other things is DoEvents. ... if you put DoEvents without Sleep in a loop ... Timer does stuff ...
    (microsoft.public.vb.general.discussion)
  • Re: Re-entrancy???
    ... In Windows you can't response in real time even if you want, ... Even without Sleep, if you need a fast response all the times, ... And if the resources are needed, DoEvents will yield to other applications//windows multi-tasking. ...
    (microsoft.public.vb.general.discussion)