Last active
December 21, 2015 04:29
-
-
Save blachniet/6250136 to your computer and use it in GitHub Desktop.
The dispose pattern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #region Dispose Pattern | |
| private bool _disposed; | |
| public void Dispose() | |
| { | |
| Dispose(true); | |
| GC.SuppressFinalize(this); | |
| } | |
| protected virtual void Dispose(bool disposing) | |
| { | |
| if (!_disposed) | |
| { | |
| if (disposing) | |
| { | |
| if (_resource != null) | |
| _resource.Dispose(); | |
| } | |
| _resource = null; | |
| _disposed = true; | |
| } | |
| } | |
| #endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment