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


C# Environment.Process方法代码示例

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

示例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();
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:8,代码来源:ProcessTest.cs

示例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));
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:9,代码来源:SteelFactory.cs

示例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);
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:9,代码来源:SimpleShop.cs

示例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;
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:15,代码来源:Program.cs

示例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));
        }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:12,代码来源:ProcessCommunication.cs

示例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);
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:13,代码来源:ProcessTest.cs

示例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);
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:14,代码来源:ContainerTest.cs

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

示例10: TestTriggeredTimeout

 public void TestTriggeredTimeout()
 {
     var env = new Environment();
       env.Process(TestTriggeredTimeout(env));
       env.Run();
       Assert.AreEqual(2, env.NowD);
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:7,代码来源:TimeoutTest.cs

示例11: Benchmark2Source

 static IEnumerable<Event> Benchmark2Source(Environment env)
 {
     while (true) {
     yield return env.Process(Benchmark2Sink(env));
     perf++;
       }
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:7,代码来源:Program.cs

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

示例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);
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:8,代码来源:ProcessTest.cs

示例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);
       }
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:8,代码来源:BankRenege.cs

示例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;
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:14,代码来源:Program.cs


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