How to support async methods in a TransactionScope with Microsoft.Bcl.Async in .NET 4.0?
问题 I have a method similar to: public async Task SaveItemsAsync(IEnumerable<MyItem> items) { using (var ts = new TransactionScope()) { foreach (var item in items) { await _repository.SaveItemAsync(item); } await _repository.DoSomethingElse(); ts.Complete(); } } This of course has issues because TransactionScope doesn't play nice with async/await. It fails with an InvalidOperationException with the message: "A TransactionScope must be disposed on the same thread that it was created." I read about