How Do I...Get the outcome of a transaction?
Transaction outcome is handled through events. To receive the outcome of a specific transaction you need to handle the TransactionCompletedEvent event which is on the Transaction object.
Here is an example of how to receive the TransactionCompletedEvent event:
1. Register for the TransactionCompletedEvent for the transaction you want to receive the outcome for
MyTx.TransactionCompleted += new TransactionCompletedEventHandler(Current_TransactionCompleted);
C#
2. Within the handler you can access the outcome of the transaction by looking at the Status property on the TransactionInformation class. This can be accessed from the TransactionEventArgs e, which is a Transaction object.
static void Current_TransactionCompleted(object sender, TransactionEventArgs e)
{
Console.WriteLine("Status: {0}", e.Transaction.TransactionInformation.Status);
Console.WriteLine("ID: {0}", e.Transaction.TransactionInformation.LocalIdentifier);
}
C#
Here is a full example:
[This sample can be found at M:\web\users\Sites\AspnetQuickStart\v2.0\QuickStart\howto\samples\Transactions\TxOutcome
To build this sample, open the SDK command prompt and navigate to the above path. Build the sample using the build tool msbuild
passing the solution file as the first parameter: msbuild mySample.sln. The compiled executable will be found in the sub directory \bin
directory.]
Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.
|