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


C# IEnvironment.Timeout方法代码示例

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


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

示例1: Worker

 static IEnumerable<IEvent> Worker(IEnvironment env)
 {
     Console.WriteLine("{0}: Carico la macchina...",
                       env.Now);
     yield return env.Timeout(LoadTime);
     env.Exit(env.Random.Choice(Tasks));
 }
开发者ID:pomma89,项目名称:Relazione-Dessert,代码行数:7,代码来源:CSharp_MachineLoad.cs

示例2: Machine

 static IEnumerable<IEvent> Machine(IEnvironment env)
 {
     while (true) {
         var worker = env.Start(Worker(env));
         yield return worker;
         Console.WriteLine("{0}: Eseguo il comando {1}",
                           env.Now, worker.Value);
         yield return env.Timeout(WorkTime);
     }
 }
开发者ID:pomma89,项目名称:Relazione-Dessert,代码行数:10,代码来源:CSharp_MachineLoad.cs

示例3: Train

 static IEvents Train(IEnvironment env)
 {
     object cause;
     string fmt;
     while (true) {
         var time = env.Random.Exponential(1.0/AvgTravelTime);
         fmt = "Treno in viaggio per {0:.00} minuti";
         Console.WriteLine(fmt, time);
         yield return env.Timeout(time);
         if (env.ActiveProcess.Interrupted(out cause))
             break;
         fmt = "Arrivo in stazione, attesa passeggeri";
         Console.WriteLine(fmt);
         yield return env.Timeout(2.Minutes());
         if (env.ActiveProcess.Interrupted(out cause))
             break;
     }
     fmt = "Al minuto {0:.00}: {1}";
     Console.WriteLine(fmt, env.Now, cause);
 }
开发者ID:pomma89,项目名称:Relazione-Dessert,代码行数:20,代码来源:CSharp_TrainInterrupt.cs

示例4: Person

 static IEvents Person(IEnvironment env, 
                       string gender, 
                       IResource toilet)
 {
     using (var req = toilet.Request()) {
         yield return req;
         Console.WriteLine("{0:0.00}: {1} --> Bagno",
                           env.Now, gender);
         var t = env.Random.Exponential(1.0/AvgTimeInToilet);
         yield return env.Timeout(t);
         Console.WriteLine("{0:0.00}: {1} <-- Bagno",
                           env.Now, gender);
     }
 }
开发者ID:pomma89,项目名称:Relazione-Dessert,代码行数:14,代码来源:CSharp_PublicToilet.cs

示例5: PersonGenerator

 static IEvents PersonGenerator(IEnvironment env)
 {
     var womenToilet = env.NewResource(1);
     var menToilet = env.NewResource(1);
     var count = 0;
     while (true) {
         var rnd = env.Random.NextDouble();
         var gn = ((rnd<0.5) ? "Donna" : "Uomo") + count++;
         var tt = (rnd<0.5) ? womenToilet : menToilet;
         Console.WriteLine("{0:0.00}: {1} in coda",
                           env.Now, gn);
         env.Start(Person(env, gn, tt));
         var t = env.Random.Exponential(1.0/AvgPersonArrival);
         yield return env.Timeout(t);
     }
 }
开发者ID:pomma89,项目名称:Relazione-Dessert,代码行数:16,代码来源:CSharp_PublicToilet.cs

示例6: PastaCook

 static IEnumerable<IEvent> PastaCook(IEnvironment env)
 {
     while (true) {
         var cookTime = env.Random.Normal(AvgCookTime,
                                          StdCookTime);
         var fmt = "Pasta in cottura per {0} minuti";
         Console.WriteLine(fmt, cookTime);
         yield return env.Timeout(cookTime);
         if (cookTime < AvgCookTime - StdCookTime)
             Console.WriteLine("Pasta poco cotta!");
         else if (cookTime > AvgCookTime + StdCookTime)
             Console.WriteLine("Pasta troppo cotta...");
         else
             Console.WriteLine("Pasta ben cotta!!!");
     }
 }
开发者ID:pomma89,项目名称:Relazione-Dessert,代码行数:16,代码来源:CSharp_PastaCooking.cs

示例7: NewTarget

 static ITimeout<string> NewTarget(IEnvironment env)
 {
     var delay = env.Random.DiscreteUniform(1, 20);
     var target = env.Random.Choice(Targets);
     return env.Timeout(delay, target);
 }
开发者ID:pomma89,项目名称:Relazione-Dessert,代码行数:6,代码来源:CSharp_TargetShooting.cs

示例8: AProcess

 static IEnumerable<IEvent> AProcess(IEnvironment env)
 {
     yield return env.Timeout(7);
     env.Exit("VAL_P");
 }
开发者ID:pomma89,项目名称:Relazione-Dessert,代码行数:5,代码来源:CSharp_ConditionTester.cs

示例9: EmergencyBrake

 static IEvents EmergencyBrake(IEnvironment env, 
                               IProcess train)
 {
     yield return env.Timeout(BreakTime);
     train.Interrupt("FRENO EMERGENZA");
 }
开发者ID:pomma89,项目名称:Relazione-Dessert,代码行数:6,代码来源:CSharp_TrainInterrupt.cs

示例10: DoSucceed

 static IEnumerable<IEvent> DoSucceed(IEnvironment env, 
                                       IEvent<object> ev)
 {
     yield return env.Timeout(5);
     ev.Succeed("SI :)");
 }
开发者ID:pomma89,项目名称:Relazione-Dessert,代码行数:6,代码来源:CSharp_EventTrigger.cs

示例11: DoFail

 static IEnumerable<IEvent> DoFail(IEnvironment env, 
                                    IEvent<object> ev)
 {
     yield return env.Timeout(5);
     ev.Fail("NO :(");
 }
开发者ID:pomma89,项目名称:Relazione-Dessert,代码行数:6,代码来源:CSharp_EventTrigger.cs


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