Setting the Consistent and Done Flags

You set the consistent and done flags by invoking methods on either the IObjectContext or the IContextState interfaces. The strategies used by these two interfaces differ significantly. IObjectContext has four methods that bind the consistent and done flags together in unique combinations, while IContextState has two methods that allow you to set each flag independently. The methods of IObjectContext are also exposed through the ObjectContext object.

For independent control of each flag, IContextState provides a method to set the consistent flag to True or False and a method to set the done flag to True or False. These methods are SetMyTransactionVote and SetDeactivateOnReturn, respectively. The IContextState interface also includes methods to retrieve the current value of each flag.

When you set the SetMyTransactionVote method value to TxCommit, COM+ verifies the presence of a transaction. If COM+ does not detect a transaction, it generates an error that you can capture in a log file. For example, suppose someone inadvertently configures your component's transaction attribute to Not Supported but you expected it to be set to Required. By setting SetMyTransactionVote = TxCommit, you can identify the conflict and take action.

The following table describes the method calls that can be used to set the consistent and done flags.

Consistent flag Done flag IObjectContext method IContextState methods
True
False
EnableCommit
SetMyTransactionVote txVote = TxCommit
SetDeactivateOnReturn bDeactivate = False
False
False
DisableCommit
SetMyTransactionVote txVote = TxAbort
SetDeactivateOnReturn bDeactivate = False
False
True
SetAbort
SetMyTransactionVote txVote = TxAbort
SetDeactivateOnReturn bDeactivate = True
True
True
SetComplete
SetMyTransactionVote txVote = TxCommit
SetDeactivateOnReturn bDeactivate = True

Note

The auto-done property, which is set at the method level, can affect how the consistent and done flags are set. For more information regarding the auto-done property, see Enabling Auto-Done for a Method and Setting the Done Bit.