Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 5633 was 5055, checked in by cneumuel, 13 years ago

#1233

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