WeakReference is an extra heap allocation per resource that basically exists to give us a finalizer - but we already have one, so we can just use GCHandle directly.
Since the default List.Remove would box the handles to compare them I had to do the Remove manually, but that allows doing an unordered remove anyway for a slight speed boost (that doesn't matter because nobody disposes resources that often)
WeakReference is an extra heap allocation per resource that basically exists to give us a finalizer - but we already have one, so we can just use GCHandle directly.
Since the default List.Remove would box the handles to compare them I had to do the Remove manually, but that allows doing an unordered remove anyway for a slight speed boost (that doesn't matter because nobody disposes resources that often)