AndyD wrote:
andur wrote:
As pointed out, that's not a very fair measurement.
I do know however, that I've wasted a *lot* of time by accidentally pressing "Rebuild Solution" instead of "Build Solution" in the build menu. "Rebuild Solution" really, really needs a "Yes/No are you sure" prompt
No it doesn't. I can't think of anything worse than constantly being asked if I really want to rebuild when that's what I actually want to do. What would help though is not having the two options right next to each other. Try rearranging the menu options and see if that works better for you.
It's always interesting to see comments like this. One feature that is a waste to someone else (for whatever reason) it a vital tool to someone else. Changes based on one person/groups perspectives is never a good thing, especially when it's something that you can work around already.
As for the topic, along with counting potentially 998 extra milliseconds for each non-responsive event or even 1000 milliseconds for any non-success condition, the original test code counts not only the sleeping (1 second) but execution of the code for the total seconds. Since there is some marshaling done in it, it's not guaranteed to be quick, though in you're worst case event (waiting 2 milliseconds). Your count would be skewed because the stopwatch will count for at least 1002 milliseconds for ever 1 seconds you add to the "wasted time". That's ignoring the fact that Thread.Sleep(1000) is only a guarantee that it will sleep for at least 1000 milliseconds not that it will wake up in exactly 1000 milliseconds. It could be delayed even longer if a higher priority thread preempts it even after it returns to the ready state. Note that these things may actually skew the analysis to be lower than what it really is. However it still means the "analysis" is faulty.
It should have been developed as the Tick/TimeElapsed event of one of the timers rather than a loop with Thread.Sleep. Or some other method of timing that is more accurate than relying on the Sleep method should have been used.
Peter Richie had a blog post about Thread.Sleep and why it is useless for keeping time and other abuses of it.
This is in addition to changes that would be needed to reconcile adding one whole second for any reason for the failed call.