I'm a bit of a threading newbie, and have just converted an app from
Threads to BackgroundWorke rs to try to get some more life out of the
UI. From reading here and elsewhere, I have a general understanding
of the "don't mess with the UI" rule and why that is.
But, what about the case where your thread fires off an async
operation? In that case, the thread's RunWorkerComple ted event fires
almost immediately. Does this mean you're safe? More specifically,
the thread only starts a WebBrowser.Navi gate, the WebBrowser
(eventually) fires a DocumentComplet e event, and in response to *that*
event, the UI gets updated. (This is the method I'm using to open ten
web pages at once in a tabbed form, and update a visible counter as
each finishes loading.)
On every machines here, that works just fine. I'm suspecting though,
that it might be behind a "cascade of JIT debug messages" reported by
a user whose machine I'm hoping to access in the next few days. But
where to look - just trying to make substantial use of these
WebBrowser controls has taught me many new ways a pc can die, so I
don't want to rush to judgement.
So the question - does the rule still apply here, meaning that I
should used a timed check to keep the BackgroundWorke rs alive until
DocumentComplet e fires, then raise an event from the thread? If I am
breaking the rule, am I any more likely to see these "intemitten t"
symptoms when I'm really overworking a machine?
If that's not a potential source, I'm still a little confused by the
whole error-handling issue when using BackgroundWorke rs. Is this
supposed to be something that can cause runtime errors, or is it just
a nuisance in the IDE? I use a standard try-catch on *every* routine,
it passes the exception to a global sub that will log the error, and
pops up a custom error form if that's enabled. The first time I read
about this, it looked like I *must* remove them from anything that
might be in a calling chain originating from a BackgroundWorke r. But,
I just haven't had any problems in the IDE - I forced some errors &
saw just what I normally would, both in and out of the IDE.
OTOH, I do not have any error handling in the DoWork event handler,
and was not using the RunWorkerComple ted event at all. Could this
mean that the JIT messages were just unhandled errors (unhandled even
though they have try-catch, because of this issue) that bubbled up to
DoWork, and had nowhere else to go?
I hope that all makes sense, because it's staring to confuse the heck
out of me. Any breadcrumbs would be greatly appreciated.
MikeB
Threads to BackgroundWorke rs to try to get some more life out of the
UI. From reading here and elsewhere, I have a general understanding
of the "don't mess with the UI" rule and why that is.
But, what about the case where your thread fires off an async
operation? In that case, the thread's RunWorkerComple ted event fires
almost immediately. Does this mean you're safe? More specifically,
the thread only starts a WebBrowser.Navi gate, the WebBrowser
(eventually) fires a DocumentComplet e event, and in response to *that*
event, the UI gets updated. (This is the method I'm using to open ten
web pages at once in a tabbed form, and update a visible counter as
each finishes loading.)
On every machines here, that works just fine. I'm suspecting though,
that it might be behind a "cascade of JIT debug messages" reported by
a user whose machine I'm hoping to access in the next few days. But
where to look - just trying to make substantial use of these
WebBrowser controls has taught me many new ways a pc can die, so I
don't want to rush to judgement.
So the question - does the rule still apply here, meaning that I
should used a timed check to keep the BackgroundWorke rs alive until
DocumentComplet e fires, then raise an event from the thread? If I am
breaking the rule, am I any more likely to see these "intemitten t"
symptoms when I'm really overworking a machine?
If that's not a potential source, I'm still a little confused by the
whole error-handling issue when using BackgroundWorke rs. Is this
supposed to be something that can cause runtime errors, or is it just
a nuisance in the IDE? I use a standard try-catch on *every* routine,
it passes the exception to a global sub that will log the error, and
pops up a custom error form if that's enabled. The first time I read
about this, it looked like I *must* remove them from anything that
might be in a calling chain originating from a BackgroundWorke r. But,
I just haven't had any problems in the IDE - I forced some errors &
saw just what I normally would, both in and out of the IDE.
OTOH, I do not have any error handling in the DoWork event handler,
and was not using the RunWorkerComple ted event at all. Could this
mean that the JIT messages were just unhandled errors (unhandled even
though they have try-catch, because of this issue) that bubbled up to
DoWork, and had nowhere else to go?
I hope that all makes sense, because it's staring to confuse the heck
out of me. Any breadcrumbs would be greatly appreciated.
MikeB
Comment