ContextUtil.MyTransactionVote Eigenschaft
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Ruft das consistent Bit im COM+-Kontext ab oder legt es fest.
public:
static property System::EnterpriseServices::TransactionVote MyTransactionVote { System::EnterpriseServices::TransactionVote get(); void set(System::EnterpriseServices::TransactionVote value); };
public static System.EnterpriseServices.TransactionVote MyTransactionVote { get; set; }
static member MyTransactionVote : System.EnterpriseServices.TransactionVote with get, set
Public Shared Property MyTransactionVote As TransactionVote
Eigenschaftswert
Einer der TransactionVote Werte, entweder Commit oder Abort.
Ausnahmen
Es ist kein COM+-Kontext verfügbar.
Beispiele
Im folgenden Codebeispiel wird die Verwendung MyTransactionVote der Eigenschaft zum Erstellen einer Transaktion ServicedComponentveranschaulicht.
[assembly:System::Reflection::AssemblyKeyFile("Transaction.snk")];
[Transaction]
public ref class TransactionalComponent: public ServicedComponent
{
public:
void TransactionalMethod( String^ data )
{
ContextUtil::DeactivateOnReturn = true;
ContextUtil::MyTransactionVote = TransactionVote::Abort;
// do work with data
ContextUtil::MyTransactionVote = TransactionVote::Commit;
}
};
[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;
}
}
<Transaction()> _
Public Class TransactionalComponent
Inherits ServicedComponent
Public Sub TransactionalMethod(ByVal data As String)
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
End Sub
End Class
Hinweise
Wenn MyTransactionVote sie auf Commit"COM+" festgelegt ist, wird das COM+ consistent -Bit und die COM+-Kontextstimmen festgelegt true , um die Transaktion zu übernehmen. Wenn MyTransactionVote diese Option auf Abort"Bit" festgelegt ist, wird das consistent Bit auf "COM+" festgelegt false , und die COM+-Kontextstimmen, um die Transaktion abzubrechen. Der Standardwert des consistent Bits ist true.
Das consistent Bit gibt eine Stimme ab, um die Transaktion, in der sie ausgeführt wird, zu übernehmen oder abzubrechen, und das done Bit schließt die Abstimmung ab. COM+ überprüft das consistent Bit, wenn das done Bit für einen Methodenaufruf zurückgegeben true wird oder wenn das Objekt deaktiviert wird. Obwohl sich das Bit eines Objekts innerhalb jedes Methodenaufrufs consistent wiederholt ändern kann, zählt nur die letzte Änderung.