ContextUtil.MyTransactionVote Property

Definition

Gets or sets the consistent bit in the COM+ context.

C#
public static System.EnterpriseServices.TransactionVote MyTransactionVote { get; set; }

Property Value

One of the TransactionVote values, either Commit or Abort.

Exceptions

There is no COM+ context available.

Examples

The following code example demonstrates how to use MyTransactionVote property to create a transactional ServicedComponent.

C#
[Transaction]
public class TransactionalComponent : ServicedComponent
{

    public void TransactionalMethod (string data)
    {

      ContextUtil.DeactivateOnReturn = true;
      ContextUtil.MyTransactionVote = TransactionVote.Abort;

      // Do work with data. Return if any errors occur.

      // Vote to commit. If any errors occur, this code will not execute.
      ContextUtil.MyTransactionVote = TransactionVote.Commit;
    }
}

Remarks

When MyTransactionVote is set to Commit, the COM+ consistent bit is set to true and the COM+ context votes to commit the transaction. If MyTransactionVote is set to Abort, the consistent bit is set to false and the COM+ context votes to abort the transaction. The default value of the consistent bit is true.

The consistent bit casts a vote to commit or abort the transaction in which it executes, and the done bit finalizes the vote. COM+ inspects the consistent bit when the done bit is set to true on a method call return or when the object deactivates. Although an object's consistent bit can change repeatedly within each method call, only the last change counts.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1