我嘗試用這個代碼:C#4.0的任務庫僵局
foreach (var r in _vm.Rules.Take(20)) {
Task.Factory.StartNew(() => {
new SQLRuleSerializer().SaveRule(_vm.SelectedKey, r);
});
}
錯誤:
Transaction (Process ID 600) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
我不知道這究竟是如何鎖死考慮到我沒有任何明確的鎖..我想問題是,序列化程序是一個代理,不能並行調用,即使通過單獨的實例?
ahhhhh ..好點。謝謝 –