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 dieses 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 veranschaulicht, wie mithilfe der MyTransactionVote Eigenschaft eine Transaktion ServicedComponenterstellt wird.
[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 auf Commitfestgelegt ist, wird das COM+ consistent -Bit auf true festgelegt, und der COM+-Kontext stimmt ab, um die Transaktion zu commiten. Wenn MyTransactionVote auf Abortfestgelegt ist, wird das consistent Bit auf false festgelegt, und der COM+-Kontext stimmt ab, um die Transaktion abzubrechen. Der Standardwert des consistent Bits ist true.
Das consistent Bit gibt eine Stimme ab, um die Transaktion, in der es ausgeführt wird, zu commiten oder abzubrechen, und das done Bit beendet die Abstimmung. COM+ überprüft das consistent Bit, wenn das done Bit bei true einem Methodenaufruf auf festgelegt ist 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.