Beyond Your Control
Catching exceptions using try statements works only if your code appears somewhere higher up on the call stack. After all, a protected block protects only the code that runs inside it. You don’t possess magical powers to stretch an exception handler around code that is not yours, somewhere in an unrelated corner of the system.
A typical source of such practical issues is in UI programming, where a dispatcher is used to run work on behalf of the user, on the right thread and with a specified right priority. The code that dispatches work items that have been scheduled is beyond your control. For example, in Windows Presentation Foundation (WPF), it’s the application’s Run method that starts the dispatcher. Here is a minimalistic ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access