I\'m trying to use the new async/await feature to asynchronously work with a DB. As some of the requests can be lengthy, I want to be able to cancel them. The issue I\'m run
I know this is an old thread, but if anyone has run into the problem System.InvalidOperationException : A TransactionScope must be disposed on the same thread that it was created.
The solution is to upgrade to .net 4.5.1 at a minimum and use a transaction like the following:
using (var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
//Run some code here, like calling an async method
await someAsnycMethod();
transaction.Complete();
}
Now the transaction is shared between methods. Take a look at the link below. It provide a simple example and more detail
For complete details, take a look at This