The Context (and DataScope) are not thread safe.

Posts   
 
    
yowl
User
Posts: 271
Joined: 11-Feb-2008
# Posted on: 18-Jan-2022 21:04:36   

Looking at this stack trace Type:System.IndexOutOfRangeException Message:Index was outside the bounds of the array. Stack: at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at SD.LLBLGen.Pro.ORMSupportClasses.Context.AddEntity(IEntityCore toAdd) at SD.LLBLGen.Pro.ORMSupportClasses.Context.Add[TEntity](TEntity toAdd) at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.AddContainedEntitiesToContext() at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.set_ActiveContext(Context value) at SD.LLBLGen.Pro.ORMSupportClasses.Context.Add(IEntityCollectionCore toAdd) at SD.LLBLGen.Pro.ORMSupportClasses.DataScope.Attach(IEntityCollectionCore toAttach)

I'm guessing its because I need to synchronize updates to the DataScope/Context, is that correct?

yowl
User
Posts: 271
Joined: 11-Feb-2008
# Posted on: 18-Jan-2022 21:06:10   

LLBLGen 5.8 BTW.

Walaa avatar
Walaa
Support Team
Posts: 14986
Joined: 21-Aug-2005
# Posted on: 18-Jan-2022 21:50:39   

From the docs:

As the Context class doesn't use any locking mechanism, the Context object isn't thread-safe and should be used for single-thread semantic contexts

yowl
User
Posts: 271
Joined: 11-Feb-2008
# Posted on: 18-Jan-2022 21:53:37   

Thanks, I guess "single-thread semantic contexts" just means that if I lock it myself than that's ok.