Dispose pattern usage -


i read these articles on dispose pattern , dispose implementation. question when calling virtual dispose(bool) method finalizer, why pass false method , release unmanaged resource? if pass true, break?

also have implemented idisposble interface, still relies on developer either wrap code in using block or call dispose() explicitly, in order dispose() method invoked. addon of idisposble interface, if developer not careful enough?

from first link:

the boolean parameter disposing indicates whether method invoked idisposable.dispose implementation or finalizer. dispose(bool) implementation should check parameter before accessing other reference objects (e.g., resource field in preceding sample). such objects should accessed when method called idisposable.dispose implementation (when disposing parameter equal true). if method invoked finalizer (disposing false), other objects should not accessed. the reason objects finalized in unpredictable order , they, or of dependencies, might have been finalized.

hope helps.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo