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


C# Machine.Start方法代碼示例

本文整理匯總了C#中System.Machine.Start方法的典型用法代碼示例。如果您正苦於以下問題:C# Machine.Start方法的具體用法?C# Machine.Start怎麽用?C# Machine.Start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Machine的用法示例。


在下文中一共展示了Machine.Start方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ShouldGuardPeripheralReads

		public void ShouldGuardPeripheralReads([Range(1, 4)] int cpuCount)
		{
			using(var machine = new Machine())
			{
				var sysbus = machine.SystemBus;
				cpuCount.Times(() => sysbus.Register(new ActivelyAskingCPU(machine, 0), new CPURegistrationPoint()));
				var peripheral = new ActivelyAskedPeripheral(); 
				sysbus.Register(peripheral, 0.To(1000));
				machine.Start();
				Thread.Sleep(1000);
				machine.Pause();
				Assert.IsFalse(peripheral.Failed, "Peripheral was concurrently accessed from multiple CPUs.");
			}
		}
開發者ID:rte-se,項目名稱:emul8,代碼行數:14,代碼來源:MultiCPUTests.cs

示例2: ShouldBeDescending

 public void ShouldBeDescending()
 {
     using(var machine = new Machine())
     {
         var timer = new LimitTimer(machine, 100, 100000, Direction.Descending, true);
         var manualClockSource = new ManualClockSource();
         machine.SetClockSource(manualClockSource);
         machine.Start();
         var oldValue = timer.Limit;
         for(var i = 0; i < 100; i++)
         {
             manualClockSource.AdvanceBySeconds(1);
             var value = timer.Value;
             Assert.Less(value, oldValue, "Timer is not monotonic.");
             oldValue = value;
         }
         machine.Pause();
     }
 }
開發者ID:bhuvanchandra,項目名稱:emul8,代碼行數:19,代碼來源:CoreTimerTest.cs

示例3: ShouldNotExceedLimitAscending

 public void ShouldNotExceedLimitAscending()
 {
     var limit = 100;
     using(var machine = new Machine())
     {
         var timer = new LimitTimer(machine, 1, limit, Direction.Ascending, true);
         var manualClockSource = new ManualClockSource();
         machine.SetClockSource(manualClockSource);
         machine.Start();
         manualClockSource.AdvanceBySeconds(limit - 1);
         for(var i = 0; i < 3; ++i)
         {
             var value = timer.Value;
             Assert.LessOrEqual(value, limit, "Timer exceeded given limit.");
             Assert.GreaterOrEqual(value, 0, "Timer returned negative value.");
             manualClockSource.AdvanceBySeconds(1);
         }
         Thread.Sleep(7);
         machine.Pause();
     }
 }
開發者ID:bhuvanchandra,項目名稱:emul8,代碼行數:21,代碼來源:CoreTimerTest.cs

示例4: ShouldPauseAndResumeOnlyOnce

		public void ShouldPauseAndResumeOnlyOnce()
		{
			using(var machine = new Machine())
			{
                var sb = machine.SystemBus;
				var mock = new Mock<IHasOwnLife>();
                sb.Register(mock.As<IDoubleWordPeripheral>().Object, 0.To(100));
                sb.Register(new Mock<ICPU>().Object, new CPURegistrationPoint());
				machine.Start();
                PauseResumeRetries.Times(machine.Pause);
				mock.Verify(x => x.Pause(), Times.Once());
                PauseResumeRetries.Times(machine.Start);
				mock.Verify(x => x.Resume(), Times.Once());
			}
		}
開發者ID:emul8,項目名稱:emul8,代碼行數:15,代碼來源:SystemBusTests.cs

示例5: ShouldFireAlarmWhenInterruptsAreEnabled

 public void ShouldFireAlarmWhenInterruptsAreEnabled()
 {
     using(var machine = new Machine())
     {
         var timer = new LimitTimer(machine, 1, 10, Direction.Descending, true);
         var manualClockSource = new ManualClockSource();
         machine.SetClockSource(manualClockSource);
         timer.EventEnabled = true;
         var ticked = false;
         timer.LimitReached += () => ticked = true;
         machine.Start();
         // var val =timer.Value;
         manualClockSource.AdvanceBySeconds(110);
         Assert.IsTrue(ticked);
     }
 }
開發者ID:bhuvanchandra,項目名稱:emul8,代碼行數:16,代碼來源:CoreTimerTest.cs

示例6: ShouldSwitchDirectionProperly

 public void ShouldSwitchDirectionProperly()
 {
     using(var machine = new Machine())
     {
         var timer = new LimitTimer(machine, 100, 100000, Direction.Ascending, true);
         var manualClockSource = new ManualClockSource();
         machine.SetClockSource(manualClockSource);
         timer.EventEnabled = true;
         var ticked = false;
         timer.LimitReached += () => ticked = true;
         machine.Start();
         manualClockSource.AdvanceBySeconds(2);
         timer.Direction = Direction.Descending; // and then change the direction
         manualClockSource.AdvanceBySeconds(2);
         Assert.IsTrue(ticked);
       
     }
 }
開發者ID:bhuvanchandra,項目名稱:emul8,代碼行數:18,代碼來源:CoreTimerTest.cs


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