Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/TransactionManager.cs @ 5593

Last change on this file since 5593 was 5055, checked in by cneumuel, 14 years ago

#1233

  • added test project
File size: 951 bytes
RevLine 
[4649]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Services.Hive.Common;
6using System.Transactions;
7using HeuristicLab.Common;
[5055]8using HeuristicLab.Clients.Common;
[4649]9
10namespace HeuristicLab.Services.Hive.DataAccess {
11  public class TransactionManager {
12    public Disposable<TransactionScope> OpenTransaction() {
[4796]13      TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = ApplicationConstants.IsolationLevelScope });
[4649]14      var disposable = new Disposable<TransactionScope>(transaction);
[5055]15      disposable.OnDisposing += new EventHandler<EventArgs<object>>(disposable_OnDisposing);
[4649]16      return disposable;
17    }
18
[5055]19    void disposable_OnDisposing(object sender, EventArgs<object> e) {
20      TransactionScope scope = (TransactionScope)e.Value;
21      scope.Complete();
22      scope.Dispose();
[4649]23    }
24  }
25}
Note: See TracBrowser for help on using the repository browser.