/// <summary> /// Performs all scheduled disposal calls and cleans up internal data. This is done automatically at the /// end of each <see cref="Update">frame update</see> and you shouldn't need to call this in general. /// Invoking this method while an update is still in progress may result in undefined behavior. Don't do this. /// </summary> public static void RunCleanup() { // Perform scheduled object disposals object[] disposeScheduleArray; bool lockTaken = false; try { disposeScheduleLock.Enter(ref lockTaken); disposeScheduleArray = disposeSchedule.ToArray(); disposeSchedule.Clear(); } finally { if (lockTaken) { disposeScheduleLock.Exit(); } } foreach (object o in disposeScheduleArray) { IManageableObject m = o as IManageableObject; if (m != null) { m.Dispose(); continue; } IDisposable d = o as IDisposable; if (d != null) { d.Dispose(); continue; } } // Perform late finalization and remove disposed object references Resource.RunCleanup(); Scene.Current.RunCleanup(); }
private static void RunCleanup() { foreach (object o in disposeSchedule) { IManageableObject m = o as IManageableObject; if (m != null) { m.Dispose(); continue; } IDisposable d = o as IDisposable; if (d != null) { d.Dispose(); continue; } } disposeSchedule.Clear(); Resource.RunCleanup(); Scene.Current.RunCleanup(); }
/// <summary> /// Performs all scheduled disposal calls and cleans up internal data. This is done automatically at the /// end of each <see cref="Update()">frame update</see> and you shouldn't need to call this in general. /// Invoking this method while an update is still in progress may result in undefined behavior. Don't do this. /// </summary> public static void RunCleanup() { // Perform scheduled object disposals object[] disposeScheduleArray = disposeSchedule.ToArray(); disposeSchedule.Clear(); foreach (object o in disposeScheduleArray) { IManageableObject m = o as IManageableObject; if (m != null) { m.Dispose(); continue; } IDisposable d = o as IDisposable; if (d != null) { d.Dispose(); continue; } } // Perform late finalization and remove disposed object references Resource.RunCleanup(); }