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
...
