An alternative to UBB.threads
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
FLocal/Web.Core/DB/Transaction.cs

50 lines
907 B

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Web.Core.DB {
abstract public class Transaction : IDisposable {
protected Transaction() {
this.finalized = false;
}
abstract protected void do_Commit();
abstract protected void do_Rollback();
public bool finalized {
get;
private set;
}
public void Commit() {
lock(this) {
if(this.finalized) throw new CriticalException("Already finalized");
this.do_Commit();
this.finalized = true;
}
}
public void Rollback() {
lock(this) {
if(this.finalized) throw new CriticalException("Already finalized");
this.do_Rollback();
this.finalized = true;
}
}
public void Dispose() {
lock(this) {
if(!this.finalized) {
this.do_Rollback();
this.finalized = true;
}
}
}
}
}