public static void CommitTransaction() { lock (_lock) { if (Transaction != null) { _timer.Dispose(); _timer = null; if (ManagementUnit.CommitRequested) { try { ManagementUnit.ServerManager.CommitChanges(); } catch { AbortTransaction(); throw; } } Transaction = null; ManagementUnit.Dispose(); ManagementUnit = null; } } }
public static void AbortTransaction() { lock (_lock) { if (_timer != null) { _timer.Dispose(); _timer = null; } Transaction = null; if (ManagementUnit != null) { ManagementUnit.Dispose(); ManagementUnit = null; } } }
public static Transaction BeginTransaction() { lock (_lock) { if (Transaction == null) { var transaction = new Transaction(); transaction.ExpiresOn = transaction.CreatedOn.AddMilliseconds(TRANSACTION_IDLE_TIMEOUT); _timer = new Timer(TimeoutCallback, null, TRANSACTION_IDLE_TIMEOUT, Timeout.Infinite); ManagementUnit = new ManagementUnit(transaction); Transaction = transaction; } } return(Transaction); }