【发布时间】:2011-11-18 19:29:03
【问题描述】:
如果我执行以下操作:
Using scope = New TransactionScope()
entries.Content.ReadAs(Of IList(Of WebMaint)).AsParallel.ForAll(Sub(entry)
_repos.Update(entry)
End Sub)
scope.Complete()
End Using
TransactionScope 不起作用。如果我在 scope.complete 上设置断点,则没有事务处于活动状态并且更新已经完成。
如果我将其更改为:
Using scope = New TransactionScope()
entries.Content.ReadAs(Of IList(Of WebMaint)).ToList().ForEach(Sub(entry)
_repos.Update(entry)
End Sub)
scope.Complete()
End Using
一切都按预期进行。有人知道为什么并行版本不能正常工作吗?
【问题讨论】:
标签: .net transactionscope parallel-extensions