Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ClassName : IDisposable
- {
- #region Variable Declarations
- private bool _disposed = false;
- #endregion
- #region Constructors & Destructors
- public ClassName()
- {
- }
- ~ClassName()
- {
- //Invoke the helper class that will clean up and release any applicable resources.
- //Note that we are passing a false which indicates that the Garbage Collector
- //triggered the clean up.
- ReleaseResources(false);
- }
- #endregion
- #region IDisposable Interface Methods
- public void Dispose()
- {
- //Invoke the helper class that will clean up and release any applicable resources.
- //Note that we are passing a true which indicates that the method was invoked by
- //the caller/user.
- ReleaseResources(true);
- //Suppress the Finalization step of the Garbage Collector.
- GC.SuppressFinalize(this);
- }
- private void ReleaseResources(bool disposing)
- {
- //Ensure that the object has not already been disposed.
- if (!this._disposed)
- {
- if (disposing)
- {
- //Clean up and dispose of all MANAGED resources here.
- }
- //Clean up and dispose of all UNMANAGED resources here.
- }
- //Indicate that the object has already been disposed.
- this._disposed = true;
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement