ContextUtil.DeactivateOnReturn Property

Definition

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

C#
public static bool DeactivateOnReturn { get; set; }

Property Value

true if the object is to be deactivated when the method returns; otherwise, false. The default is false.

Exceptions

There is no COM+ context available.

Examples

The following code example demonstrates the use of the DeactivateOnReturn property to ensure that a ServicedComponent is deactivated after a method call.

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

The COM+ done bit determines how long the object remains active after finishing its work and can affect the duration of a transaction. When a method call returns, COM+ inspects the done bit. If the done bit is true, COM+ deactivates the object. If the done bit is false, the object is not deactivated.

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