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


C# Environment.Run方法代码示例

本文整理汇总了C#中System.Environment.Run方法的典型用法代码示例。如果您正苦于以下问题:C# Environment.Run方法的具体用法?C# Environment.Run怎么用?C# Environment.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Environment的用法示例。


在下文中一共展示了Environment.Run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: TestExit

 public void TestExit()
 {
     // Processes can set a return value
       var executed = false;
       var env = new Environment(new DateTime(1970, 1, 1, 0, 0, 0));
       env.Process(ExitParent(env, () => executed = true));
       env.Run();
       Assert.IsTrue(executed);
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:9,代码来源:ProcessTest.cs

示例5: 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

示例6: 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

示例7: 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

示例8: TestChildException

 public void TestChildException()
 {
     // A child catches an exception and sends it to its parent.
       // This is the same as TestExit
       var executed = false;
       var env = new Environment(new DateTime(1970, 1, 1, 0, 0, 0));
       env.Process(ChildExceptionParent(env, () => executed = true));
       env.Run();
       Assert.IsTrue(executed);
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:10,代码来源:ProcessTest.cs

示例9: TestEventQueueEmpty

 public void TestEventQueueEmpty()
 {
     /*The simulation should stop if there are no more events, that means, no
     more active process.*/
       var log = new List<string>();
       var env = new Environment();
       env.Process(AProcess(env, log));
       env.Run(TimeSpan.FromMinutes(10));
       Assert.IsTrue(log.SequenceEqual(new[] { "00", "01" }));
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:10,代码来源:EnvironmentTests.cs

示例10: TestAnyOfEmptyList

 public void TestAnyOfEmptyList()
 {
     var env = new Environment();
       var evt = new AnyOf(env, Enumerable.Empty<Event>());
       Assert.IsTrue(evt.IsTriggered);
       Assert.IsFalse(evt.IsProcessed);
       env.Run(evt);
       Assert.IsTrue(evt.IsProcessed);
       Assert.AreEqual(0, env.NowD);
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:10,代码来源:ConditionTest.cs

示例11: Invoke

 public object Invoke(Environment e, object[] args)
 {
     foreach (object o in argnames)
     {
         // FIXME
         e.Set(o.ToString(), e.GetObject(o.ToString()));
     }
     return e.Run(Pieces.ToArray());
     // TODO: remove args from env
 }
开发者ID:mlnlover11,项目名称:Notepad-X,代码行数:10,代码来源:AST.cs

示例12: TestFilterCallsBestCase

 public void TestFilterCallsBestCase()
 {
     var env = new Environment();
       var store = new FilterStore(env, new object[] { 1, 2, 3 }, 3);
       var log = new List<string>();
       Func<object, bool> filterLogger = o => { log.Add(string.Format("check {0}", o)); return true; };
       env.Process(TestFilterCallsBestCaseProcess(store, filterLogger, log));
       env.Run();
       Assert.IsTrue(log.SequenceEqual(new[] { "check 1", "get 1", "check 2", "get 2", "check 3", "get 3" }));
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:10,代码来源:ResourceTest.cs

示例13: Benchmark1

 /// <summary>
 /// This method will benchmark Sim#'s performance with respect to the list
 /// of future events. A large number of processes that exist in the system
 /// stress tests the performance of operations on the event queue.
 /// </summary>
 /// <param name="n">The number of concurrent processes.</param>
 static long Benchmark1(Environment env, int n)
 {
     perf = 0;
       for (var i = 0; i < n; i++) {
     env.Process(Benchmark1Proc(env, n));
       }
       var watch = Stopwatch.StartNew();
       env.Run(terminate);
       watch.Stop();
       return watch.ElapsedTicks;
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:17,代码来源:Program.cs

示例14: 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

示例15: Simulate

        private static readonly TimeSpan MinPatience = TimeSpan.FromMinutes(1); // Min. customer patience

        #endregion Fields

        #region Methods

        public void Simulate(int rseed = 41)
        {
            // Setup and start the simulation
              var start = new DateTime(2014, 2, 1);
              // Create an environment and start the setup process
              var env = new Environment(start, 41);
              env.Log("== Bank renege ==");
              var counter = new Resource(env, capacity: 1);
              env.Process(Source(env, counter));
              env.Run();
        }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:17,代码来源:BankRenege.cs


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