| Platform SDK: Transaction Server |
ITransactionContext.Abort, ITransactionContext.Commit Methods Example
[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]
import com.ms.mtx.*;
ITransactionContextEx myTransactionContext = null;
IMyObject myObject = null;
boolean userCanceled = false;
// Get TransactionContextEx.
myTransactionContext = new TransactionContextEx();
// Create an instance of MyObject.
myObject = myTransactionContext.CreateInstance (CMyObject.clsid, IMyObject.iid);
// Do some work here.
// If something goes wrong, abort the transaction.
if (userCanceled)
myTransactionContext.Abort();
// Otherwise, commit it.
else
pTransactionContext.Commit();