好好学习,天天向上,一流范文网欢迎您!
当前位置: >> 总结 >> 学习总结 内容页

INDOUBT PreparingEnlistment类

PreparingEnlistment 类定义

命名空间:

System.Transactions

程序集:

netstandard.dll, System.Transactions.Local.dll

程序集:

System.Transactions.Local.dll

程序集:

System.Transactions.dll

程序集:

netstandard.dll

Source:

PreparingEnlistment.cs

Source:

PreparingEnlistment.cs

Source:

PreparingEnlistment.cs

Source:

PreparingEnlistment.cs

Source:

PreparingEnlistment.cs

重要

一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。

在事务准备阶段,促进登记的事务参与者和事务管理器之间的通信。

public ref class PreparingEnlistment : System::Transactions::Enlistment

public class PreparingEnlistment : System.Transactions.Enlistment

type PreparingEnlistment = class
    inherit Enlistment

Public Class PreparingEnlistment
Inherits Enlistment

继承

示例

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();
    }
}

Public Class EnlistmentClass
    Implements IEnlistmentNotification
    Public Sub Prepare(ByVal myPreparingEnlistment As PreparingEnlistment) Implements System.Transactions.IEnlistmentNotification.Prepare
        Console.WriteLine("Prepare notification received")
        'Perform transactional work
        'If work finished correctly, reply with prepared
        myPreparingEnlistment.Prepared()
    End Sub
    Public Sub Commit(ByVal myEnlistment As Enlistment) Implements System.Transactions.IEnlistmentNotification.Commit
        Console.WriteLine("Commit notification received")
        'Do any work necessary when commit notification is received
        'Declare done on the enlistment
        myEnlistment.Done()
    End Sub
    Public Sub Rollback(ByVal myEnlistment As Enlistment) Implements System.Transactions.IEnlistmentNotification.Rollback
        Console.WriteLine("Rollback notification received")
        'Do any work necessary when rollback notification is received
        'Declare done on the enlistment
        myEnlistment.Done()
    End Sub
    Public Sub InDoubt(ByVal myEnlistment As Enlistment) Implements System.Transactions.IEnlistmentNotification.InDoubt
        Console.WriteLine("In doubt notification received")
        'Do any work necessary when indout notification is received
        'Declare done on the enlistment
        myEnlistment.Done()
    End Sub
End Class

注解

在事务的初始(准备)阶段INDOUBT起步网校,事务管理器通过调用 Prepare 方法来获取资源对事务的投票INDOUBT,将此类型传递给资源管理器。 根据它是否投票决定提交或回滚,资源管理器的实现应调用 Prepared 此类型的或 ForceRollback 方法。

资源管理器还可以在调用该方法之前Prepared随时调用Done该方法。 通过这样做,登记将投票为只读投票,这意味着它投票提交事务,但不需要收到最终结果。

持久资源管理器可以检索事务管理器从属性重新登记 所需的信息。 有关恢复的详细信息,请参阅 执行恢复。

方法 名称说明

指示事务参与者已完成其工作。

(继承自 Enlistment)

确定指定的对象是否等于当前对象。

(继承自 Object)

指示应回滚事务。

指示应回滚事务。

用作默认哈希函数。

(继承自 Object)

获取当前实例的 Type。

(继承自 Object)

创建当前 Object的浅表副本。

(继承自 Object)

指示可以提交事务。

获取登记的恢复信息。

返回一个表示当前对象的字符串。

(继承自 Object)

线程安全性

此类型是线程安全的。

另请参阅