本文整理汇总了C#中System.Environment.Process方法的典型用法代码示例。如果您正苦于以下问题:C# Environment.Process方法的具体用法?C# Environment.Process怎么用?C# Environment.Process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Environment
的用法示例。
在下文中一共展示了Environment.Process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestAndConditionBlocked
public void TestAndConditionBlocked()
{
var env = new Environment();
env.Process(TestAndConditionBlockedProcess(env));
env.RunD(5);
Assert.AreEqual(5, env.NowD);
}
示例2: TestGetState
public void TestGetState()
{
// A process is alive until it's generator has not terminated.
var env = new Environment();
var procA = env.Process(GetStatePemA(env));
env.Process(GetStatePemB(env, procA));
env.Run();
}
示例3: Simulate
public void Simulate()
{
var env = new Environment(TimeSpan.FromMinutes(1));
env.Log("== Steel Factory ==");
var crane = new Resource(env, 1);
env.Process(Cast(env, crane, "CC1", new[] { new Slab(4), new Slab(4), new Slab(8), new Slab(3), new Slab(2) }));
env.Process(Cast(env, crane, "CC2", new[] { new Slab(2), new Slab(3), new Slab(3), new Slab(4), new Slab(3) }));
env.Run(TimeSpan.FromMinutes(100));
}
示例4: Simulate
public void Simulate()
{
var env = new Environment(randomSeed: 41);
var packer = new Resource(env, 1);
env.Process(Machine(env, packer));
env.Process(Machine(env, packer));
env.Run(TimeSpan.FromHours(8));
Console.WriteLine("The machines were delayed for {0}", delay);
}
示例5: Benchmark3
/// <summary>
/// This method will benchmark Sim#'s performance with respect to
/// seizing and releasing resources, a common task in DES models.
/// </summary>
static long Benchmark3(Environment env)
{
perf = 0;
var res = new Resource(env, capacity: 1);
env.Process(Benchmark3Proc(env, res));
env.Process(Benchmark3Proc(env, res));
var watch = Stopwatch.StartNew();
env.Run(terminate);
watch.Stop();
return watch.ElapsedTicks;
}
示例6: Simulate
public void Simulate(int rseed = 42)
{
// Setup and start the simulation
var env = new Environment(rseed, TimeSpan.FromSeconds(1));
env.Log("== Process communication ==");
var pipe = new Store(env);
env.Process(MessageGenerator("Generator A", env, pipe));
env.Process(MessageConsumer("Consumer A", env, pipe));
env.Run(TimeSpan.FromSeconds(100));
}
示例7: TestInterruptedJoin
public void TestInterruptedJoin()
{
/* Tests that interrupts are raised while the victim is waiting for
another process. The victim should get unregistered from the other
process.
*/
var executed = false;
var env = new Environment(new DateTime(1970, 1, 1, 0, 0, 0));
var parent = env.Process(InterruptedJoinParent(env, () => executed = true));
env.Process(InterruptedJoinInterruptor(env, parent));
env.Run();
Assert.IsTrue(executed);
}
示例8: TestContainer
public void TestContainer()
{
var start = new DateTime(2014, 4, 2);
var env = new Environment(start);
var buf = new Container(env, initial: 0, capacity: 2);
var log = new List<Tuple<char, DateTime>>();
env.Process(TestContainerPutter(env, buf, log));
env.Process(TestContainerGetter(env, buf, log));
env.Run(TimeSpan.FromSeconds(5));
var expected = new List<Tuple<char, int>> {
Tuple.Create('p', 1), Tuple.Create('g', 1), Tuple.Create('g', 2), Tuple.Create('p', 2)
}.Select(x => Tuple.Create(x.Item1, start + TimeSpan.FromSeconds(x.Item2))).ToList();
CollectionAssert.AreEqual(expected, log);
}
示例9: Simulate
private static readonly TimeSpan TankTruckTime = TimeSpan.FromMinutes(10); // Minutes it takes the tank truck to arrive
#endregion Fields
#region Methods
public void Simulate(int rseed = RandomSeed)
{
// Setup and start the simulation
// Create environment and start processes
var env = new Environment(rseed);
env.Log("== Gas Station refuelling ==");
var gasStation = new Resource(env, 2);
var fuelPump = new Container(env, GasStationSize, GasStationSize);
env.Process(GasStationControl(env, fuelPump));
env.Process(CarGenerator(env, gasStation, fuelPump));
// Execute!
env.Run(SimTime);
}
示例10: TestTriggeredTimeout
public void TestTriggeredTimeout()
{
var env = new Environment();
env.Process(TestTriggeredTimeout(env));
env.Run();
Assert.AreEqual(2, env.NowD);
}
示例11: Benchmark2Source
static IEnumerable<Event> Benchmark2Source(Environment env)
{
while (true) {
yield return env.Process(Benchmark2Sink(env));
perf++;
}
}
示例12: TestFilterCallsWorstCase
public void TestFilterCallsWorstCase()
{
var env = new Environment();
var store = new FilterStore(env, 4);
var log = new List<string>();
Func<object, bool> filterLogger = o => { log.Add(string.Format("check {0}", o)); return (int)o >= 3; };
env.Process(TestFilterCallsWorseCaseGetProcess(store, filterLogger, log));
env.Process(TestFilterCallsWorstCasePutProcess(store, log));
env.Run();
Assert.IsTrue(log.SequenceEqual(new[] {
"put 0", "check 0",
"put 1", "check 0", "check 1",
"put 2", "check 0", "check 1", "check 2",
"put 3", "check 0", "check 1", "check 2", "check 3", "get 3"
}));
}
示例13: TestErrorAndInterruptedJoin
public void TestErrorAndInterruptedJoin()
{
var executed = false;
var env = new Environment(new DateTime(1970, 1, 1, 0, 0, 0));
env.Process(ErrorAndInterruptedJoinParent(env, () => executed = true));
env.Run();
Assert.IsTrue(executed);
}
示例14: Source
private IEnumerable<Event> Source(Environment env, Resource counter)
{
for (int i = 0; i < NewCustomers; i++) {
var c = Customer(env, "Customer " + i, counter, TimeSpan.FromMinutes(12.0));
env.Process(c);
yield return env.TimeoutExponential(IntervalCustomers);
}
}
示例15: Benchmark2
/// <summary>
/// This method will benchmark Sim#'s performance with respect to creation
/// of entities. In SimPy and also Sim# the equivalence of an entity is a
/// process. This stress tests the performance of creating processes.
/// </summary>
static long Benchmark2(Environment env)
{
perf = 0;
env.Process(Benchmark2Source(env));
var watch = Stopwatch.StartNew();
env.Run(terminate);
watch.Stop();
return watch.ElapsedTicks;
}