Last active
March 8, 2017 23:47
-
-
Save Porges/1a4082e6be45333f03b0da37d7dc9af4 to your computer and use it in GitHub Desktop.
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
ref class Foo | |
{ | |
public: | |
!Foo() | |
{ | |
Console::WriteLine("I'm being finalized!"); | |
} | |
~Foo() | |
{ | |
Console::WriteLine("I'm being destroyed!"); | |
this->!Foo(); | |
} | |
}; |
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
class Foo : IDisposable | |
{ | |
~Foo() | |
{ | |
this.Dispose(false); | |
} | |
private void !Foo() | |
{ | |
Console.WriteLine("I'm being finalized!"); | |
} | |
private void !Foo() | |
{ | |
Console.WriteLine("I'm being destroyed!"); | |
this.!Foo(); | |
} | |
[HandleProcessCorruptedStateExceptions] | |
protected virtual void Dispose([MarshalAs(UnmanagedType.U1)] bool A_0) | |
{ | |
if (A_0) | |
{ | |
this.~Foo(); | |
} | |
else | |
{ | |
try | |
{ | |
this.!Foo(); | |
} | |
finally | |
{ | |
// ISSUE: explicit finalizer call | |
base.Finalize(); | |
} | |
} | |
} | |
public virtual void Dispose() | |
{ | |
this.Dispose(true); | |
GC.SuppressFinalize((object) this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment