本文整理汇总了C#中System.Transactions.CommittableTransaction.BeginCommit方法的典型用法代码示例。如果您正苦于以下问题:C# CommittableTransaction.BeginCommit方法的具体用法?C# CommittableTransaction.BeginCommit怎么用?C# CommittableTransaction.BeginCommit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Transactions.CommittableTransaction
的用法示例。
在下文中一共展示了CommittableTransaction.BeginCommit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsyncFail1
public void AsyncFail1 ()
{
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 );
IAsyncResult ar2 = ct.BeginCommit ( null, null );
}
示例2: AsyncFail1
public void AsyncFail1 ()
{
ExceptionAssert.Throws<InvalidOperationException>(
delegate
{
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);
IAsyncResult ar2 = ct.BeginCommit(null, null);
});
}
示例3: 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 );
}
示例4: AsyncFail3
public void AsyncFail3 ()
{
delayedException = null;
IntResourceManager irm = new IntResourceManager ( 1 );
CommittableTransaction ct = new CommittableTransaction ();
/* Set ambient Tx */
Transaction.Current = ct;
/* Enlist */
irm.Value = 2;
irm.FailPrepare = true;
callback = new AsyncCallback (CommitCallback);
IAsyncResult ar = ct.BeginCommit ( callback, 5 );
mr.WaitOne (new TimeSpan (0, 0, 60), true);
Assert.IsTrue ( called, "callback not called" );
Assert.AreEqual ( 5, state, "state not preserved" );
if ( delayedException.GetType () != typeof ( TransactionAbortedException ) )
Assert.Fail ( "Expected TransactionAbortedException, got {0}", delayedException.GetType () );
}
示例5: Async5
public void Async5 ()
{
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 );
ar.AsyncWaitHandle.WaitOne ();
Assert.IsTrue ( ar.IsCompleted );
try {
CommittableTransaction ctx = ar as CommittableTransaction;
ctx.EndCommit ( ar );
} catch ( TransactionAbortedException ) {
irm.Check ( 1, 0, 0, 0, "irm" );
return;
}
Assert.Fail ("EndCommit should've failed");
}
示例6: Async4
public void Async4 ()
{
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 );
ar.AsyncWaitHandle.WaitOne ();
Assert.IsTrue ( ar.IsCompleted );
irm.Check ( 1, 1, 0, 0, "irm" );
}
示例7: 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" );
}
示例8: 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" );
}
示例9: Async1
public void Async1 ()
{
IntResourceManager irm = new IntResourceManager ( 1 );
CommittableTransaction ct = new CommittableTransaction ();
/* Set ambient Tx */
Transaction.Current = ct;
/* Enlist */
irm.Value = 2;
callback = new AsyncCallback (CommitCallback);
IAsyncResult ar = ct.BeginCommit ( callback, 5);
mr.WaitOne (new TimeSpan (0, 2, 0), true);
Assert.IsTrue (called, "callback not called" );
Assert.AreEqual ( 5, state, "State not received back");
if ( delayedException != null )
throw new Exception ("", delayedException );
}
示例10: ExplicitTransaction13
public void ExplicitTransaction13 ()
{
CommittableTransaction ct = new CommittableTransaction ();
IntResourceManager irm = new IntResourceManager ( 1 );
Assert.IsNull ( Transaction.Current );
Transaction.Current = ct;
irm.Value = 2;
irm.FailPrepare = true;
try {
ct.Commit ();
} catch ( TransactionAbortedException ) {
Assert.AreEqual ( TransactionStatus.Aborted, ct.TransactionInformation.Status );
try {
ct.BeginCommit ( null, null );
} catch (Exception) {
Transaction.Current = null;
return;
}
Assert.Fail ( "Should not be reached(2)" );
}
Assert.Fail ("Should not be reached");
}
示例11: ExplicitTransaction12
public void ExplicitTransaction12 ()
{
CommittableTransaction ct = new CommittableTransaction ();
IntResourceManager irm = new IntResourceManager ( 1 );
irm.FailPrepare = true;
ct.BeginCommit ( null, null );
ct.EndCommit ( null );
}
示例12: 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 ();
}
示例13: ExplicitTransaction9
public void ExplicitTransaction9 ()
{
CommittableTransaction ct = new CommittableTransaction ();
IntResourceManager irm = new IntResourceManager ( 1 );
ct.BeginCommit ( null, null );
ct.BeginCommit ( null, null );
}
示例14: ExplicitTransaction9
public void ExplicitTransaction9 ()
{
ExceptionAssert.Throws<InvalidOperationException>(
delegate
{
CommittableTransaction ct = new CommittableTransaction();
IntResourceManager irm = new IntResourceManager(1);
ct.BeginCommit(null, null);
ct.BeginCommit(null, null);
});
}
示例15: 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);
});
}