Peter Duniho said:
[...]
If you've got some sort of button that fires off this
process that takes a long time then that button can be clicked twice in
either case and you need to check for this in either case. The user
could
potentially double click the button.
Impossible as long as the code correctly disables the button after the
first click and not reenabled until the BackgroundWorker's
RunWorkerCompleted event is raised.
And the same thing is true whether the processing is implemented using
threading or DoEvents(). This is a complete red herring, totally
irrelevant.
I thought you said these things were completely different. Now you say
they
are the same.
You're being obtuse. I believe you're doing so intentionally.
What I said was that the potential _dangerous_ issues are different. You
And I disagree. Most of the trouble can be summarized as "the object can be
accessed when another operation is in-progress and the state is
inconsistent". This is true for both re-entrancy and multi-threading, and
it is worse for multithreading (with re-entrance, if an operation is in
progress, you know it is stopped at one of a finite number of interruption
points, but with multithreading, the other operation can be at any point and
may not even be stopped). OTOH, using a lock to solve the problem is easier
with threading, since depending on whether the lock is re-entrant or not,
locks in re-entrance will either deadlock the task or do nothing at all.
But this is somewhat a case of "when all you have is a hammer, everything
looks like a nail". Threading and re-entrancy present similar problems but
have to be addressed with different tools. In the end, though, both have to
guarantee atomicity of operations that restore consistency of the data
structures, and this is trivial to do in the re-entrant case, and commonly
uses locks in the threaded case.