onnxruntime/csharp/src/Microsoft.ML.OnnxRuntime/NativeOnnxObjectHandle.cs
2018-11-22 20:56:43 -08:00

28 lines
602 B
C#

using System;
using System.Runtime.InteropServices;
namespace Microsoft.ML.OnnxRuntime
{
internal class NativeOnnxObjectHandle : SafeHandle
{
public NativeOnnxObjectHandle(IntPtr ptr)
: base(IntPtr.Zero, true)
{
handle = ptr;
}
public override bool IsInvalid
{
get
{
return (handle == IntPtr.Zero);
}
}
protected override bool ReleaseHandle()
{
NativeMethods.ONNXRuntimeReleaseObject(handle);
return true;
}
}
}