Hello, dear.
I do double sorting on the link (priority sheet), sort it, output it to IEnumerable
, but when I try queue.Any()
ArgumentException
is thrown. Google is already half an hour, but I still can not understand the reason.
Help me to understand.
private readonly List<BaseBotAction> _actions = new List<BaseBotAction>(); // abstract IEnumerable<BaseBotAction> queue = from action in _actions orderby action.Priority() ascending, action.StartTime ascending select action; if (queue.Any()) { //ArgumentException here var action = queue.First(); // Something... }
Thrace:
2013-10-24 20:58:20,714 [Thread-Bot-Manager-PriorityQueue] ERROR EBot.ClientsManager [(null)] - System.ArgumentException: Длина результирующего массива недостаточна. Проверьте значения destIndex и length, а также нижние границы массива. в System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable) в System.Collections.Generic.List`1.CopyTo(T[] array, Int32 arrayIndex) в System.Linq.Buffer`1..ctor(IEnumerable`1 source) в System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext() в System.Linq.Enumerable.Any[TSource](IEnumerable`1 source) в EBot.BotInstance.PriorityQueueRun() в D:\CSharp\EBot\BotInstance.cs:строка 47
order by
suddenly there was not enough allocated buffer. Either in the LINQ bug, or in some way, the collection changed during the execution ofAny
. --- You are welcome! - VladD