Re: How do I wait until myVar == true



Gabriel Magaña wrote:
> Jeez people, I gave the guy a warning about using DoEvents()...

Where, out of interest? I didn't spot a warning.

> It's nothing more than a quickie, a properly-written application should be
> multithreaded/etc... And absolutely polling is a thing of the past.
> Sometimes, though, it's not worth the effort. If what you want to do is
> simple and the user won't care about some unresponsiveness, then I stand by
> my statement, spend 45 seconds writing a polling loop statement rather than
> whatever long it takes to do a multi-threaded "proper" app.

The trouble is that you spend 45 seconds writing it now - and then
hours later, trying to debug a recursion problem. If the user won't
care about it not being responsive, don't put the call to DoEvents() in
at all. It'll look terrible, but at least you won't have a nasty
threading issue to debug.

> I was just giving the guy some choices.
>
> Christoph - I specifically warned against that...
> Willy - I never said to use DoEvents() in an alternate thread.
> Jon - Your point is well-taken and I agree that proper design is always
> better, but sometimes you are in search of a quick solution, for example if
> you are quickly writing a data import routine that no end user will ever
> see. User inreface responsiveness and saving every clock cycle possible is
> not a huge priority. Delivery time might be the big priority (and usually
> is).

Delivery time is a priority for me, too. If I'm spending ages
maintaining a previous rushed version which had horrible threading
issues, I can't spend as much time developing new features.

Hacking together poorly designed code never helps in the long run.

It's not a case of trying to save every clock cycle (regulars here will
know I'm not a fan of micro-optimisation). It's a case of trying to do
the Right Thing.

Jon

.



Relevant Pages