Skip to content

Instantly share code, notes, and snippets.

@Porges
Last active March 8, 2017 23:47
Show Gist options
  • Save Porges/1a4082e6be45333f03b0da37d7dc9af4 to your computer and use it in GitHub Desktop.
Save Porges/1a4082e6be45333f03b0da37d7dc9af4 to your computer and use it in GitHub Desktop.
ref class Foo
{
public:
!Foo()
{
Console::WriteLine("I'm being finalized!");
}
~Foo()
{
Console::WriteLine("I'm being destroyed!");
this->!Foo();
}
};
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