W
Wavemaker
I have a class written in C# which uses a worker thread
internally to do some processing. It's possible that an
exceptional situation can arise in the worker thread, and as
the class is presently written, it throws an exception in
those cases.
But I don't think this is a good design. I don't see how
these exceptions can be caught. Plus, exiting a thread by
throwing an exception probably isn't very clean either.
So I was thinking about using events instead. When an
exceptional situation arises in the worker thread, have it
raise an event letting clients know about the problem.
The XmlValidatingReader class use an ValidationEventHandler
for passing exceptions through events, so there is a
precedence for this approach.
Anyway, I'd appreciate advice. Thanks.
internally to do some processing. It's possible that an
exceptional situation can arise in the worker thread, and as
the class is presently written, it throws an exception in
those cases.
But I don't think this is a good design. I don't see how
these exceptions can be caught. Plus, exiting a thread by
throwing an exception probably isn't very clean either.
So I was thinking about using events instead. When an
exceptional situation arises in the worker thread, have it
raise an event letting clients know about the problem.
The XmlValidatingReader class use an ValidationEventHandler
for passing exceptions through events, so there is a
precedence for this approach.
Anyway, I'd appreciate advice. Thanks.