Dealing with Exceptions

Unhandled exceptions occurring on any thread cause the application to be terminated by the CLR. Because of this, it’s essential to guard your thread entry-point methods against unhandled exceptions if specific types of exceptions are tolerable. For example, threads handling user requests should not be able to take down the entire web or application server unless something really exceptional happens (such as memory corruption, out-of-memory situations, stack overflows, and so on).

This does not imply you should use the “catch-all” technique because this could silence way too many exceptions that could cause damage later during the application’s execution (for example, because of broken invariants). In other words, one should ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.