خرید بک لینک

Vote count: 0

Is there a way to open multiple TransactionScopes concurrently in a single .NET thread and switch between them? Something along the lines of:

var tx1 = new TransactionScope(...);
var tx2 = new TransactionScope(...);

tx1.Use();
// do some database operations on tx1

tx2.Use();
// do some database operations on tx2
tx2.Complete();

tx1.Use();
// do some more database operations on tx1
tx1.Complete();

I want to test some concurrency situations in my database, and keeping the concurrent producers on a single thread would allow me to write neater test code:

producer1.DoA(); // must run in txA
producer2.DoB(); // must run in txB
...

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 21 فروردين 1395 ساعت: 2:58

صفحه بندی