Created
January 8, 2015 22:52
-
-
Save jonpryor/96f4bbb482b3a58613ba to your computer and use it in GitHub Desktop.
This file contains 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
// SafeHandle.Close()... | |
using System; | |
using System.Runtime.InteropServices; | |
class MySafeHandle : SafeHandle { | |
public MySafeHandle () | |
: base (IntPtr.Zero, ownsHandle:false) | |
{ | |
} | |
protected override bool ReleaseHandle () | |
{ | |
return true; | |
} | |
public override bool IsInvalid { | |
get {return base.handle == IntPtr.Zero;} | |
} | |
} | |
class App { | |
public static void Main () | |
{ | |
var h = new MySafeHandle (); | |
h.Close (); | |
h.Close (); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment