Variable/Field value not being held

From: Chris (anonymous_at_discussions.microsoft.com)
Date: 04/14/04


Date: Tue, 13 Apr 2004 18:34:01 -0700

A for-next loop is not the equivalent of a pause. Sure it
wastes time, but it's busy. Try a DoEvents statement. Or
two.

>-----Original Message-----
>This is driving me crazy.
>Basically - I have a checkbox on a form that when ticked
opens a
>second form. Various functions are performed and values
are written to
>this form and into variables. From this form the
variables are passed
>back and used to populate additonal fields on the first
form...
>All except on one field/variable! This field is a sum
field on the
>second form. The value of this field is written to the
variable and
>passed back as with the others, however when reading this
variable
>back into a field on the first form ~ Code runs through
without
>breaking ~ but the actual value returned is always 0 -
unless I put a
>breakpoint in, and then when I run the form, it breaks at
this point,
>all I need do is F5 to continue running the code and !!!
it returns
>the expected (correct) value
>
>On the surface it seems to be a timing issue. I've put in
a simple
>For/Next loop to pause but this doesn't make any
difference. I also
>suspected that it may be something to do with the value
being
>calculated on the form, and if the form hadn't been drawn
on screen
>yet then how could the calculation take place ~ not so, I
have added
>code to calculate the expected total from values held
before the form
>is drawn... it still returns 0 unless a breakpoint is
added
>.
>



Relevant Pages

  • Re: Thread.Suspend()
    ... //Can run this anytime ... how does the thread "pause" while it's waiting for the autoresetevent? ... It it in a busy-wait loop or is the thread blocked? ... I only wanted to be able to pause the thread because the calculation takes some serious power and using other apps in the meantime is a pain. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Thread.Suspend()
    ... The dangerous of Suspend is that it suspends the hardware thread, at whatever position it is currently being executed. ... why not to perform calculation based on the load of CPU? ... AB> In my current use of wanting to pause threads, ... AB> (depending on which part of the loop it was at when pause was ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ntdll.dll shown to take 30% in profiler
    ... loop called Resume for each thread. ... The calculation was ... My next attemp was to put an infinite loop in Execute(until program ... something in the NT kernel. ...
    (borland.public.delphi.language.basm)
  • Re: for loop faster than vectorized
    ... ML tries best to look at code and optimise it for you, ... It might throw off the internal MATLAB 'tweaker' and you would ... Say do a rand inside the loop: ... when using small vectors and running the calculation more ...
    (comp.soft-sys.matlab)
  • Re: Multithreading / Scalability
    ... By pulling out the result-assignment of the inner loop, ... amount of cache invalidations are reduced greatly. ... calculation, *instead of* making the switch to summing into a local ... private void multithreaded_calculation ...
    (comp.lang.java.programmer)