void Dispose(bool disposing) { if (!IsEmpty) { if (disposing) { // de-reference the managed resource. PPBCore.ReleaseResource(this); } ppresource = 0; // set ourselves to empty } }
/// <summary> /// Method that will release all the PPResource's that have been placed on the queue to be released. /// </summary> /// <param name="result"></param> void ReleasePump(PPError result) { if (!resourceReleaseQueue.IsEmpty) { object resourceToBeReleased; while (resourceReleaseQueue.TryDequeue(out resourceToBeReleased)) { if (resourceToBeReleased is PPResource) { PPBCore.ReleaseResource((PPResource)resourceToBeReleased); } else if (resourceToBeReleased is PPVar) { PPBVar.Release((PPVar)resourceToBeReleased); } } } PPBCore.CallOnMainThread(releaseLoopTime, new CompletionCallback(ReleasePump), releaseLoopTime); }
/// <summary> /// ReleaseResource() decrements the reference count for the provided /// <code>resource</code>. The resource will be deallocated if the /// reference count reaches zero. /// </summary> /// <param name="resource">A <code>Resource</code> corresponding to a /// resource.</param> public static void ReleaseResource(Resource resource) => PPBCore.ReleaseResource(resource);