本文整理汇总了C#中System.Machine.Pause方法的典型用法代码示例。如果您正苦于以下问题:C# Machine.Pause方法的具体用法?C# Machine.Pause怎么用?C# Machine.Pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Machine
的用法示例。
在下文中一共展示了Machine.Pause方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
}
}
示例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();
}
}
示例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();
}
}