Hi All
I have the following method:
/// <summary>
/// Gets the specified side of trades.
/// </summary>
/// <param name="tradesDictionary">The trades dictionary.</param>
/// <param name="side">The side.</param>
public IEnumerable<TradeRecord> GetTrades(Dictionary<Guid, TradeRecord> tradesDictionary, Side side)
{
return (from tradeRecord in tradesDictionary.Values.ToList().AsParallel()
where (tradeRecord.OrderRecord.PairRecord.Id == _pairId)
&& (tradeRecord.Side == side.ToString())
orderby tradeRecord.Date, tradeRecord.DateCreated, tradeRecord.Id
select tradeRecord);
}
Which causes the following exception:
Destination array is not long enough to copy all the items in the collection. Check array index and length.
The dictionary passed in, is constantly increasing in size. I wasn't getting the error before, the only thing that has changed is the volume of data in the tradesDictionary.
- Why does this exception happen?
- How do i prevent it from happening?