當前位置: 首頁>>代碼示例>>C#>>正文


C# Transactions.IntResourceManager類代碼示例

本文整理匯總了C#中MonoTests.System.Transactions.IntResourceManager的典型用法代碼示例。如果您正苦於以下問題:C# IntResourceManager類的具體用法?C# IntResourceManager怎麽用?C# IntResourceManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IntResourceManager類屬於MonoTests.System.Transactions命名空間,在下文中一共展示了IntResourceManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Vol1_Dur0_2PC

		public void Vol1_Dur0_2PC ()
		{
			IntResourceManager irm = new IntResourceManager (1);

			using (TransactionScope scope = new TransactionScope ()) {
				irm.Value = 2;

				scope.Complete ();
			}
			irm.Check2PC ("irm");
		}
開發者ID:HarrievG,項目名稱:mono,代碼行數:11,代碼來源:EnlistTest.cs

示例2: Vol1_Dur0_Fail3

		public void Vol1_Dur0_Fail3 ()
		{
			IntResourceManager irm = new IntResourceManager (1);
			irm.UseSingle = true;
			irm.FailSPC = true;

			using (TransactionScope scope = new TransactionScope ()) {
				irm.Value = 2;

				scope.Complete ();
			}
		}
開發者ID:HarrievG,項目名稱:mono,代碼行數:12,代碼來源:EnlistTest.cs

示例3: Vol1_Dur0_Fail1

		public void Vol1_Dur0_Fail1 ()
		{
			IntResourceManager irm = new IntResourceManager (1);
			irm.UseSingle = true;
			using (TransactionScope scope = new TransactionScope ()) {
				irm.Value = 2;

				/* Not completing this..
				scope.Complete ();*/
			}

			irm.Check ( 0, 0, 0, 1, 0, 0, 0, "irm" );
		}
開發者ID:HarrievG,項目名稱:mono,代碼行數:13,代碼來源:EnlistTest.cs

示例4: 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

示例5: TransactionScopeAbort

		public void TransactionScopeAbort ()
		{
			Assert.IsNull (Transaction.Current, "Ambient transaction exists");
			IntResourceManager irm = new IntResourceManager (1);
			using (TransactionScope scope = new TransactionScope ()) {
				Assert.IsNotNull (Transaction.Current, "Ambient transaction does not exist");
				Assert.AreEqual (TransactionStatus.Active, Transaction.Current.TransactionInformation.Status, "transaction is not active");

				irm.Value = 2;
				/* Not completing scope here */
			}
			irm.Check ( 0, 0, 1, 0, "irm");
			Assert.AreEqual (1, irm.Value);
			Assert.IsNull (Transaction.Current, "Ambient transaction exists");
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:15,代碼來源:TransactionScopeTest.cs

示例6: 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

示例7: NestedTransactionScope1

		public void NestedTransactionScope1 ()
		{
			IntResourceManager irm = new IntResourceManager (1);

			Assert.IsNull (Transaction.Current, "Ambient transaction exists");
			using (TransactionScope scope = new TransactionScope ()) {
				irm.Value = 2;

				/* Complete this scope */
				scope.Complete ();
			}

			Assert.IsNull (Transaction.Current, "Ambient transaction exists");
			/* Value = 2, got committed */
			Assert.AreEqual (irm.Value, 2, "#1");
			irm.Check ( 1, 1, 0, 0, "irm" );
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:17,代碼來源:TransactionScopeTest.cs

示例8: Vol1_Dur0_Fail2

		public void Vol1_Dur0_Fail2 ()
		{
		    ExceptionAssert.Throws<TransactionAbortedException>(
		        delegate
		            {
			            IntResourceManager irm = new IntResourceManager(1);

			            irm.FailPrepare = true;

			            using (TransactionScope scope = new TransactionScope())
                        {
				            irm.Value = 2;

				            scope.Complete();
                        }
                    });
		}
開發者ID:tohosnet,項目名稱:Mono.Data.Sqlite,代碼行數:17,代碼來源:EnlistTest.cs

示例9: 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

示例10: Vol2_Dur1_Fail3

		public void Vol2_Dur1_Fail3 ()
		{
			IntResourceManager [] irm = new IntResourceManager [4];
			irm [0] = new IntResourceManager ( 1 );
			irm [1] = new IntResourceManager ( 3 );
			irm [2] = new IntResourceManager ( 5 );
			irm [3] = new IntResourceManager ( 7 );

			irm [0].Type = ResourceManagerType.Durable;
			irm [2].FailPrepare = true;

			for ( int i = 0; i < 4; i++ )
				irm [i].UseSingle = true;

			/* Durable RM irm[2] does on SPC, so
			 * all volatile RMs get Rollback */
			try {
				using (TransactionScope scope = new TransactionScope ()) {
					irm [0].Value = 2;
					irm [1].Value = 6;
					irm [2].Value = 10;
					irm [3].Value = 14;

					scope.Complete ();
				}
			}
			catch (TransactionAbortedException) {
				irm [0].Check ( 0, 0, 0, 1, 0, 0, 0, "irm [0]");

				/* irm [1] & [2] get prepare,
				 * [2] -> ForceRollback,
				 * [1] & [3] get rollback,
				 * [0](durable) gets rollback */
				irm [1].Check ( 0, 1, 0, 1, 0, 0, 0, "irm [1]" );
				irm [2].Check ( 0, 1, 0, 0, 0, 0, 0, "irm [2]" );
				irm [3].Check ( 0, 0, 0, 1, 0, 0, 0, "irm [3]" );

				return;
			}

			Assert.Fail ( "Expected TransactionAbortedException" );
		}
開發者ID:HarrievG,項目名稱:mono,代碼行數:42,代碼來源:EnlistTest.cs

示例11: Vol2_Dur1_Fail2b

		public void Vol2_Dur1_Fail2b()
		{
			TransactionAbortedException exception = null;
			IntResourceManager[] irm = new IntResourceManager[4];
			irm[0] = new IntResourceManager(1);
			irm[1] = new IntResourceManager(3);
			irm[2] = new IntResourceManager(5);
			irm[3] = new IntResourceManager(7);

			irm[0].IgnoreSPC = true;
			irm[1].Type = ResourceManagerType.Durable;

			for (int i = 0; i < 4; i++)
				irm[i].UseSingle = true;

			/* Durable RM irm[2] does on SPC, so
			 * all volatile RMs get Rollback */
			try
			{
				using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 0, 5)))
				{
					irm[0].Value = 2;
					irm[1].Value = 6;
					irm[2].Value = 10;
					irm[3].Value = 14;

					scope.Complete();
				}
			}
			catch (TransactionAbortedException ex)
			{
				irm[0].CheckSPC("irm [0]");

				/* Volatile RMs get 2PC Prepare, and then get rolled back */
				for (int i = 1; i < 4; i++)
					irm[i].Check(0, 1, 0, 1, 0, 0, 0, "irm [" + i + "]");

				exception = ex;
			}

			Assert.IsNotNull(exception, "Expected TransactionAbortedException not thrown!");
			Assert.IsNotNull(exception.InnerException, "TransactionAbortedException has no inner exception!");
			Assert.AreEqual(typeof(TimeoutException), exception.InnerException.GetType());
		}
開發者ID:HarrievG,項目名稱:mono,代碼行數:44,代碼來源:EnlistTest.cs

示例12: Vol2_Dur1_Fail1

		public void Vol2_Dur1_Fail1 ()
		{
			IntResourceManager [] irm = new IntResourceManager [4];
			irm [0] = new IntResourceManager (1);
			irm [1] = new IntResourceManager (3);
			irm [2] = new IntResourceManager (5);
			irm [3] = new IntResourceManager (7);

			irm [0].Type = ResourceManagerType.Durable;
			irm [0].FailSPC = true;

			for ( int i = 0; i < 4; i++ )
				irm [i].UseSingle = true;

			/* Durable RM irm[0] does Abort on SPC, so
			 * all volatile RMs get Rollback */
			try {
				using (TransactionScope scope = new TransactionScope ()) {
					irm [0].Value = 2;
					irm [1].Value = 6;
					irm [2].Value = 10;
					irm [3].Value = 14;

					scope.Complete ();
				}
			}
			catch (TransactionAbortedException) {
				irm [0].CheckSPC ( "irm [0]" );
				/* Volatile RMs get 2PC Prepare, and then get rolled back */
				for (int i = 1; i < 4; i++)
					irm [i].Check ( 0, 1, 0, 1, 0, 0, 0, "irm [" + i + "]" );
			}
		}
開發者ID:HarrievG,項目名稱:mono,代碼行數:33,代碼來源:EnlistTest.cs

示例13: TransactionDispose

		public void TransactionDispose ()
		{
			CommittableTransaction ct = new CommittableTransaction ();
			IntResourceManager irm = new IntResourceManager (1);
			irm.Type = ResourceManagerType.Durable;

			ct.Dispose ();
			irm.Check  (0, 0, 0, 0, "Dispose transaction");
		}
開發者ID:HarrievG,項目名稱:mono,代碼行數:9,代碼來源:EnlistTest.cs

示例14: 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

示例15: Vol0_Dur0_Pspe2

		public void Vol0_Dur0_Pspe2 ()
		{
			IntResourceManager irm0 = new IntResourceManager (1);
			IntResourceManager irm1 = new IntResourceManager (1);
			irm0.Type = ResourceManagerType.Promotable;
			irm1.Type = ResourceManagerType.Promotable;
			using (TransactionScope scope = new TransactionScope ()) {
				irm0.Value = 8;
				irm1.Value = 2;
				Assert.AreEqual(0, irm1.NumEnlistFailed, "PSPE enlist did not fail although PSPE RM was already enlisted");
			}
		}
開發者ID:HarrievG,項目名稱:mono,代碼行數:12,代碼來源:EnlistTest.cs


注:本文中的MonoTests.System.Transactions.IntResourceManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。