本文整理汇总了C#中System.Transactions.CommittableTransaction.EndCommit方法的典型用法代码示例。如果您正苦于以下问题:C# CommittableTransaction.EndCommit方法的具体用法?C# CommittableTransaction.EndCommit怎么用?C# CommittableTransaction.EndCommit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Transactions.CommittableTransaction
的用法示例。
在下文中一共展示了CommittableTransaction.EndCommit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsyncFail2
public void AsyncFail2 ()
{
IntResourceManager irm = new IntResourceManager ( 1 );
CommittableTransaction ct = new CommittableTransaction ();
/* Set ambient Tx */
Transaction.Current = ct;
/* Enlist */
irm.Value = 2;
irm.FailPrepare = true;
IAsyncResult ar = ct.BeginCommit ( null, null );
ct.EndCommit ( ar );
}
示例2: Async3
public void Async3 ()
{
IntResourceManager irm = new IntResourceManager ( 1 );
CommittableTransaction ct = new CommittableTransaction ();
/* Set ambient Tx */
Transaction.Current = ct;
/* Enlist */
irm.Value = 2;
IAsyncResult ar = ct.BeginCommit ( null, null );
ct.EndCommit ( ar );
irm.Check ( 1, 1, 0, 0, "irm" );
}
示例3: Async2
public void Async2 ()
{
IntResourceManager irm = new IntResourceManager ( 1 );
CommittableTransaction ct = new CommittableTransaction ();
using ( TransactionScope scope = new TransactionScope (ct) ) {
irm.Value = 2;
//scope.Complete ();
IAsyncResult ar = ct.BeginCommit ( null, null);
try {
ct.EndCommit ( ar );
}
catch ( TransactionAbortedException) {
irm.Check ( 0, 0, 1, 0, "irm" );
return;
}
}
Assert.Fail ( "EndCommit should've thrown an exception" );
}
示例4: ExplicitTransaction12
public void ExplicitTransaction12 ()
{
CommittableTransaction ct = new CommittableTransaction ();
IntResourceManager irm = new IntResourceManager ( 1 );
irm.FailPrepare = true;
ct.BeginCommit ( null, null );
ct.EndCommit ( null );
}
示例5: ExplicitTransaction10b
public void ExplicitTransaction10b ()
{
CommittableTransaction ct = new CommittableTransaction ();
IntResourceManager irm = new IntResourceManager ( 1 );
Transaction.Current = ct;
irm.Value = 2;
Transaction.Current = null;
TransactionScope scope = new TransactionScope ( ct );
Assert.AreEqual ( ct, Transaction.Current, "ambient transaction" );
//scope2.Complete ();
//scope2.Dispose ();
IAsyncResult ar = ct.BeginCommit ( null, null );
try {
ct.EndCommit (ar);
}
catch ( TransactionAbortedException) {
irm.Check ( 0, 0, 1, 0, "irm" );
Transaction.Current = null;
return;
}
Transaction.Current = null;
Assert.Fail ();
}
示例6: ExplicitTransaction12
public void ExplicitTransaction12 ()
{
ExceptionAssert.Throws<ArgumentException>(
delegate
{
CommittableTransaction ct = new CommittableTransaction();
IntResourceManager irm = new IntResourceManager(1);
irm.FailPrepare = true;
ct.BeginCommit(null, null);
ct.EndCommit(null);
});
}