Задания добавляются в HashSet разными потоками и выдают эту ошибку. Есть ли какое-нибудь решение этой проблемы?
ConcurrentDictionary _dictKeyJob;
_dictKeyJob.AddOrUpdate(myKey, key =>
{
return new HashSet({ Job };
}, (key, hashJobs) =>
{
if (Job.Status == eStatus.Cancelled)
{
hashJobs.Remove(Job);
}
else
{
hashJobs.Add(Job);
}
return hashJobs;
});
Исключение:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Collections.Generic.HashSet`1.SetCapacity(Int32 newSize, Boolean forceNewHashCodes)
at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value)
at Raj.OPS.Common.Test.c__DisplayClass38_0.b__1(mKey key, HashSet`1 hashJobs) in
at System.Collections.Concurrent.ConcurrentDictionary`2.**AddOrUpdate**(TKey key, Func`2 addValueFactory, Func`3 updateValueFactory)
Подробнее здесь: https://stackoverflow.com/questions/587 ... eexception
Метод ConcurrentDictionary AddOrUpdate, вызывающий исключение IndexOutOfRangeException ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение