It seems that, within clroni, ContextHandle.ReleaseHandle() is called by the GC when the reference count goes to 0 marking the Handle as invalid. This means that oni_destroy_ctx() is called non-deterministically. Since SafeHandleZeroOrMinusOneIsInvalid implements IDisposable, we wonder why oni_destroy_ctx() cannot be called deterministically. When is Dispose() called in this case? Is it also linked to the reference count and Handle invalid state?
It seems that, within
clroni,ContextHandle.ReleaseHandle()is called by the GC when the reference count goes to 0 marking the Handle as invalid. This means thatoni_destroy_ctx()is called non-deterministically. SinceSafeHandleZeroOrMinusOneIsInvalidimplementsIDisposable, we wonder whyoni_destroy_ctx()cannot be called deterministically. When isDispose()called in this case? Is it also linked to the reference count and Handle invalid state?