TransactionCompletedEventHandler デリゲートとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TransactionCompletedEventHandler デリゲートの意味・解説 

TransactionCompletedEventHandler デリゲート

メモ : このデリゲートは、.NET Framework version 2.0新しく追加されたものです。

Transaction クラスの TransactionCompleted イベント処理するメソッド表します

名前空間: System.Transactions
アセンブリ: System.Transactions (system.transactions.dll 内)
構文構文

Public Delegate Sub TransactionCompletedEventHandler
 ( _
    sender As Object, _
    e As TransactionEventArgs _
)
Dim instance As New TransactionCompletedEventHandler(AddressOf
 HandlerMethod)
public delegate void TransactionCompletedEventHandler
 (
    Object sender,
    TransactionEventArgs e
)
public delegate void TransactionCompletedEventHandler
 (
    Object^ sender, 
    TransactionEventArgs^ e
)
/** @delegate */
public delegate void TransactionCompletedEventHandler
 (
    Object sender, 
    TransactionEventArgs e
)
JScript では、デリゲート使用できますが、新規に宣言することはできません。

パラメータ

sender

イベントソース

e

イベント データ格納している TransactionEventArgs。

使用例使用例

アプリケーションTransactionCompleted イベントサブスクライブすることによって、トランザクション結果取得する方法次の例に示します

Public Shared Sub Main()
    Try
        Using scope As TransactionScope = New
 TransactionScope()

            'Register for the transaction completed event for the current
 transaction
            AddHandler Transaction.Current.TransactionCompleted,
 AddressOf Current_TransactionCompleted

            'Perform transactional work here.

            'Call complete on the TransactionScope based on console
 input
            Dim c As ConsoleKeyInfo
            While (True)

                Console.Write("Complete the transaction scope?
 [Y|N] ")
                c = Console.ReadKey()
                Console.WriteLine()
                If (c.KeyChar = "Y")
 Or (c.KeyChar = "y") Then
                    scope.Complete()
                    Exit While
                ElseIf ((c.KeyChar = "N")
 Or (c.KeyChar = "n")) Then
                    Exit While
                End If
                
            End While

        End Using
    Catch ex As TransactionException
        Console.WriteLine(ex)
    Catch
        Console.WriteLine("Cannot complete transaction")
        Throw
    End Try
End Sub

'Transaction completed event handler
Public Shared Sub Current_TransactionCompleted(ByVal
 sender As Object, ByVal
 e As TransactionEventArgs)
    Console.WriteLine("A transaction has completed:")
    Console.WriteLine("ID:             {0}", e.Transaction.TransactionInformation.LocalIdentifier)
    Console.WriteLine("Distributed ID: {0}", e.Transaction.TransactionInformation.DistributedIdentifier)
    Console.WriteLine("Status:         {0}", e.Transaction.TransactionInformation.Status)
    Console.WriteLine("IsolationLevel: {0}", e.Transaction.IsolationLevel)
End Sub

static void Main(string[]
 args)
{
    try
    {
        //Create the transaction scope
        using (TransactionScope scope = new
 TransactionScope())
        {
            //Register for the transaction completed event for the current
 transaction
            Transaction.Current.TransactionCompleted += new TransactionCompletedEventHandler(Current_TransactionCompleted);

            //Call complete on the TransactionScope based on console
 input
            ConsoleKeyInfo c;
            while (true)
            {
                Console.Write("Complete the transaction scope? [Y|N] ");
                c = Console.ReadKey();
                Console.WriteLine();

                if ((c.KeyChar == 'Y') || (c.KeyChar == 'y'))
                {
                    scope.Complete();
                    break;
                }
                else if ((c.KeyChar == 'N')
 || (c.KeyChar == 'n'))
                {
                    break;
                }
            }

        }

    }
    catch (System.Transactions.TransactionException ex)
    {
        Console.WriteLine(ex);
    }
    catch
    {
        Console.WriteLine("Cannot complete transaction");
        throw;
    }
}

//Transaction completed event handler
static void Current_TransactionCompleted(object
 sender, TransactionEventArgs e)
{
    Console.WriteLine("A transaction has completed:");
    Console.WriteLine("ID:             {0}", e.Transaction.TransactionInformation.LocalIdentifier);
    Console.WriteLine("Distributed ID: {0}", e.Transaction.TransactionInformation.DistributedIdentifier);
    Console.WriteLine("Status:         {0}", e.Transaction.TransactionInformation.Status);
    Console.WriteLine("IsolationLevel: {0}", e.Transaction.IsolationLevel);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からTransactionCompletedEventHandler デリゲートを検索した結果を表示しています。
Weblioに収録されているすべての辞書からTransactionCompletedEventHandler デリゲートを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からTransactionCompletedEventHandler デリゲート を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「TransactionCompletedEventHandler デリゲート」の関連用語

TransactionCompletedEventHandler デリゲートのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TransactionCompletedEventHandler デリゲートのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS