PreparingEnlistment.ForceRollback Method ()

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Indicates that the transaction should be rolled back.

Namespace:   System.Transactions
Assembly:  System.Transactions (in System.Transactions.dll)

public void ForceRollback()

An implementation of the Prepare method of the IEnlistmentNotification interface calls this method to indicate that the transaction must be rolled back.

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

.NET Framework
Available since 2.0
Return to top
Show: