title: How can I prevent the same unmanaged pointer from being encapsulated in two different SafeHandles?
body: <p>I am writing a managed wrapper for a game engine written in C to challenge myself. I have started to wrap unmanaged pointers in <code>SafeHandle</code> derivatives, but it donned on me that calls to the unmanaged functions that could return the same pointer will probably create new SafeHandles, and if one of them gets disposed, the rest of them will become invalid.</p>
  
  <p>How can I prevent this from happening efficiently? I doubt the marshaller automagically tracks duplicates...</p>