Welcome to MSDN Blogs Sign in | Join | Help

February 2009 - Posts

Be careful about exception after resource allocation

The following is a common code pattern Resource resource = GetResource(); DoWork(); return resource; If DoWork() throws exception, the resource will be leaked. We need to guard against this. For example bool success = false ; Resource resource = GetResource();
Posted by junfeng | 6 Comments
Filed under:
 
Page view tracker