Hi Vadym
Thank you for your answer.
Now my next questions:
I use the try{} catch{} block in my class. Also, I catch the
CryptographicException. When a exception occurs in my class, should I throw a
new exception within the catch block? Should I raise a custom event? Or
should I write the exception message in a public property so that I can use
the message in the main thread?
I would like to know which is the best way (the Microsoft recommend way) to
handle exceptions and work with this exceptions.
Thanks and Regards,
Dominik
-----------------------------
http://blogs.ecreation.ch
"Vadym Stetsyak" wrote:
Hello, Zemp!
ZDWhat is the correct (or best) way to handle (catch) exceptions in a
ZDclass or in a worker thread in .NET 2.0?
ZDIn my project, I've a class which do some cryptographic operations.
ZDThis class runs also in a seperate thread (not main thread). Now, how
ZDshould I handle the possible exceptions in this class?
IMO it depends on the logic of your application.
Since, your thread is doing some security related stuff, exception there may be
treated as fatal error and application will exit with appropriate status
message in the logs ( EventLog, etc).
OTOH if you received exception and you're able to recover, then
catch(...) block can simply log exception in the EventLog or any other log.
As you can see there are various ways how to handle exception.
If you will provide more specific question with more context,
then the answer will be more concrete.
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot