當前位置: 首頁>>代碼示例>>C#>>正文


C# PreparingEnlistment.ForceRollback方法代碼示例

本文整理匯總了C#中System.Transactions.PreparingEnlistment.ForceRollback方法的典型用法代碼示例。如果您正苦於以下問題:C# PreparingEnlistment.ForceRollback方法的具體用法?C# PreparingEnlistment.ForceRollback怎麽用?C# PreparingEnlistment.ForceRollback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Transactions.PreparingEnlistment的用法示例。


在下文中一共展示了PreparingEnlistment.ForceRollback方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Prepare

class myEnlistmentClass : IEnlistmentNotification
{
    public void Prepare(PreparingEnlistment preparingEnlistment)
    {
        Console.WriteLine("Prepare notification received");

        //Perform transactional work

        //If work finished correctly, reply prepared
        preparingEnlistment.Prepared();

        // otherwise, do a ForceRollback
        preparingEnlistment.ForceRollback();
    }

    public void Commit(Enlistment enlistment)
    {
        Console.WriteLine("Commit notification received");

        //Do any work necessary when commit notification is received

        //Declare done on the enlistment
        enlistment.Done();
    }

    public void Rollback(Enlistment enlistment)
    {
        Console.WriteLine("Rollback notification received");

        //Do any work necessary when rollback notification is received

        //Declare done on the enlistment
        enlistment.Done();
    }

    public void InDoubt(Enlistment enlistment)
    {
        Console.WriteLine("In doubt notification received");

        //Do any work necessary when indout notification is received
        
        //Declare done on the enlistment
        enlistment.Done();
    }
}
開發者ID:.NET開發者,項目名稱:System.Transactions,代碼行數:45,代碼來源:PreparingEnlistment.ForceRollback


注:本文中的System.Transactions.PreparingEnlistment.ForceRollback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。