/// <summary> /// Adds a dispose action to the list of pending dispose actions. These are executed /// at the end of each call to Present(). This allows GL resources to be disposed /// from other threads, such as the finalizer. /// </summary> /// <param name="disposeAction">The action to execute for the dispose.</param> internal static void AddDisposeAction(Action disposeAction) { if (disposeAction == null) { throw new ArgumentNullException("disposeAction"); } if (Threading.IsOnMainThread()) { disposeAction(); } else { lock (disposeActionsLock) { disposeActions.Add(disposeAction); } } }