UOW - A second operation started on this context before a previous asynchronous operation completed

前端 未结 2 1107
执念已碎
执念已碎 2020-12-18 22:08

I am trying following code, it has two parts, one is navigation via prism. When navigation is allowed I am starting a deep load asynchronously but each time with a new conte

2条回答
  •  余生分开走
    2020-12-18 22:31

    The problem is this code :

    _unitOfWork = _UnitOfWorkFactory.createUnitOfWorkAsync();
    
    IEnumerable relaties = await getRelatieAsync(_unitOfWork, relatieId).ConfigureAwait(true);
    
    _relatieTypeTypes = await getRelatieTypeTypesAsync(_unitOfWork, relatieId).ConfigureAwait(true);
    _relatie = relaties.FirstOrDefault();
    
     _unitOfWork.Dispose();
    

    the UnitOfWork is an instance variable, when the scenario starts a second time it is overwritten with a new instance. The already executing scenario then uses that new UnitOfWork instead of its own because it is overwritten. Not so easy to spot, but a simple race condition. I found it by replacing all instance variables by local variables and then the problem disappeared.

提交回复
热议问题