I am experimenting with this code:
foreach (var r in _vm.Rules.Take(20)) {
Task.Factory.StartNew(() => {
new SQLRuleSerializer().SaveRule(_vm.SelectedKey, r);
});
}
Error:
Transaction (Process ID 600) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
I am not sure exactly how this is deadlocking considering i do not have any explicit locks.. i guess the problems is that serializer is a proxy and cannot be called in parallel even via separate instances?
The deadlock is coming from the SQL Server, not the C# code.