private void Dispose(bool disposing) { if (handle.ToInt32() != 0) { APIFunctionSimulator.ReleaseResource(handle); handle = (IntPtr)0; } if (disposing) { bigArray = null; } }
static void UseUnmanagedResource() { IntPtr handle = APIFunctionSimulator.GetResource(); try { string result = APIFunctionSimulator.UseResource(handle); Console.WriteLine("In EntryPoint.UseUnmanagedResource, result is :" + result); } catch (Exception e) { Console.WriteLine("Exception in UseUnmanagedResource: " + e.Message); } finally { if (handle.ToInt32() != 0) { APIFunctionSimulator.ReleaseResource(handle); } } }