Created
December 12, 2017 15:31
-
-
Save szymczakk/04e490c47d7211effc9e2d6aa6940853 to your computer and use it in GitHub Desktop.
Disposable order question
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
public class NextDisposableResource: DisposableResource | |
{ | |
private DisposableResource disposableResource; | |
protected override void Dispose(bool disposing) | |
{ | |
disposableResource.Dispose(); | |
base.Dispose(disposing); | |
} | |
} | |
public class OtherDisposableResource: DisposableResource | |
{ | |
private DisposableResource disposableResource; | |
protected override void Dispose(bool disposing) | |
{ | |
base.Dispose(disposing); | |
disposableResource.Dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Klasa
NextDisposableResource
staje się właścicielemdisposableResource
więc niejako od nowa powinna zaimplementować w sobieIDisposable
pattern:Polecam świetny artykuł http://joeduffyblog.com/2005/04/08/dg-update-dispose-finalization-and-resource-management/ zwłaszcza fragmenty (z dalszymi adnotacjami):
oraz dotyczący kolejności: