public void Invoke() { if (handles != null && handles.Count > 0) { if (dirty) { handles.Sort((x, y) => y.priority - x.priority); dirty = false; } Item[] cachedHandles = handles.ToArray(); for (int i = 0; i < cachedHandles.Length; i++) { cachedHandles[i].action(); } } }