当前位置: 首页>>代码示例>>C#>>正文


C# CommittableTransaction.BeginCommit方法代码示例

本文整理汇总了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 );
		}
开发者ID:nlhepler,项目名称:mono,代码行数:14,代码来源:AsyncTest.cs

示例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);
		            });
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:18,代码来源:AsyncTest.cs

示例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 );
		}
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:AsyncTest.cs

示例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 () );
		}
开发者ID:nlhepler,项目名称:mono,代码行数:23,代码来源:AsyncTest.cs

示例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");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:25,代码来源:AsyncTest.cs

示例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" );
		}
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:AsyncTest.cs

示例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" );
		}
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:AsyncTest.cs

示例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" );
		}
开发者ID:nlhepler,项目名称:mono,代码行数:22,代码来源:AsyncTest.cs

示例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 );
		}
开发者ID:nlhepler,项目名称:mono,代码行数:20,代码来源:AsyncTest.cs

示例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");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:24,代码来源:TransactionScopeTest.cs

示例11: ExplicitTransaction12

		public void ExplicitTransaction12 ()
		{
			CommittableTransaction ct = new CommittableTransaction ();

			IntResourceManager irm = new IntResourceManager ( 1 );
			irm.FailPrepare = true;
			ct.BeginCommit ( null, null );
			ct.EndCommit ( null );
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:9,代码来源:TransactionScopeTest.cs

示例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 ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:26,代码来源:TransactionScopeTest.cs

示例13: ExplicitTransaction9

		public void ExplicitTransaction9 ()
		{
			CommittableTransaction ct = new CommittableTransaction ();

			IntResourceManager irm = new IntResourceManager ( 1 );
			ct.BeginCommit ( null, null );
			ct.BeginCommit ( null, null );
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:TransactionScopeTest.cs

示例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);
		            });
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:12,代码来源:TransactionScopeTest.cs

示例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);
		            });
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:13,代码来源:TransactionScopeTest.cs


注:本文中的System.Transactions.CommittableTransaction.BeginCommit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。