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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.