當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。