Can Monitor.Enter throw an exception?
问题 Can Monitor.Enter throw any exception. I am doing a code review and find that Monitor.Enter is before try block. Do you see any issues with in? Monitor.Enter(...) try { ... } finally { Monitor.Exit(..) } 回答1: This is the correct pattern, whether Enter() throws (can throw) or not. Only after the call to Enter() succeeds your code is under the responsibility to call Exit() . Suppose the call to Enter() fails. Then calling the corresponding Exit() is simply incorrect, it will make matters worse.