private void Update() { if (results.Count > 0) { int itemsInQueue = results.Count; lock (results) { for (int i = 0; i < itemsInQueue; i++) { PathResult result = results.Dequeue(); result.callback(result.path, result.success); } } } }