ITransactionContext.Abort, ITransactionContext.Commit Methods Example

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();