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


C# Stage.Create方法代码示例

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


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

示例1: Can_make_many_concurrent_calls

        public void Can_make_many_concurrent_calls()
        {
            var stage = new Stage();
            var a1 = stage.Create<IAdder>().Proxy;

            var start = new ManualResetEvent(false);
            var ready = new List<ManualResetEvent>();
            var tasks = new List<Task<int>>();
            for(var i = 0; i < 10; i++) {
                var i2 = i;
                var mre = new ManualResetEvent(false);
                ready.Add(mre);
                var tcs = new TaskCompletionSource<int>();
                tasks.Add(tcs.Task);
                new Thread(() => {
                    mre.Set();
                    start.WaitOne();
                    a1.Add(i2, 10).ContinueWith(t => tcs.SetResult(t.Result));
                }).Start();
            }
            WaitHandle.WaitAll(ready.ToArray());
            start.Set();
            Task.WaitAll(tasks.ToArray());
            Debug.WriteLine("all tasks completed");
            for(var i = 0; i < 10; i++) {
                Assert.AreEqual(10 + i, tasks[i].Result);

            }
        }
开发者ID:sdether,项目名称:Calculon,代码行数:29,代码来源:ActorConcurrencyTests.cs

示例2: Can_chain_actor_calls

 public void Can_chain_actor_calls()
 {
     var stage = new Stage();
     var adder = stage.Create<IAdder>().Proxy;
     var t = adder.Add(1, 1)
         .ContinueWith(t1 => adder.Add(t1.Result, 2));
     t.Wait();
     Assert.AreEqual(4, t.Unwrap().Result);
 }
开发者ID:sdether,项目名称:Calculon,代码行数:9,代码来源:StageTests.cs

示例3: Actor_can_signal_failure_via_task_of_t

 public void Actor_can_signal_failure_via_task_of_t()
 {
     var stage = new Stage();
     var a = stage.Create<IFailing>().Proxy;
     var t = a.FailImmediateOfT();
     Assert.IsTrue(Wait(t), "task never completed");
     Assert.IsTrue(t.IsFaulted, "task isn't faulted");
     Assert.IsInstanceOfType(typeof(Failure), t.Exception.GetBaseException());
 }
开发者ID:sdether,项目名称:Calculon,代码行数:9,代码来源:ActorFailureTests.cs

示例4: Can_create_child_actor

 public void Can_create_child_actor()
 {
     var stage = new Stage();
     var tester = stage.Create<IContextTester>("tester").Proxy;
     var x = tester.Can_create_child_actor().WaitForResult();
     Debug.WriteLine("ref: {0}", x.Item2);
     var a = stage.Find<IIdentity>(x.Item2);
     var id = a.Proxy.GetIdentity().WaitForResult();
     Assert.AreEqual(id, x.Item1);
 }
开发者ID:sdether,项目名称:Calculon,代码行数:10,代码来源:ActorContextTests.cs

示例5: Ask_vs_tell_sequential

 public void Ask_vs_tell_sequential()
 {
     var stage = new Stage();
     var perf = stage.Create<IPerfSender>().Proxy;
     var n = 100000;
     var ask = perf.AskSequential(n).WaitForResult();
     Console.WriteLine("{0:0.00} asks/s", n / ask.TotalSeconds);
     var tell = perf.TellSequential(n).WaitForResult();
     Console.WriteLine("{0:0.00} tells/s", n / tell.TotalSeconds);
 }
开发者ID:sdether,项目名称:Calculon,代码行数:10,代码来源:MessagingPerfTests.cs

示例6: Can_create_and_call_actor

 public void Can_create_and_call_actor()
 {
     var stage = new Stage();
     var adder = stage.Create<IAdder>().Proxy;
     var t1 = adder.Add(1, 1);
     var t2 = adder.Add(2, 2);
     t1.Wait();
     t2.Wait();
     Assert.AreEqual(2, t1.Result);
     Assert.AreEqual(4, t2.Result);
 }
开发者ID:sdether,项目名称:Calculon,代码行数:11,代码来源:StageTests.cs

示例7: Awake

 // Use this for initialization
 void Awake()
 {
     StageBuilder.scale = scale;
     stage = new Stage(lair.ToString(), floor_material, wall_material, fluff_builder);
     stage.Create();
     player = GameObject.FindGameObjectWithTag("Player");
     player.transform.position = playerSpawn;
     Instantiate(boss, bossSpawn, Quaternion.identity);
     log = GameObject.FindWithTag("Log").GetComponent<NotificationLog>();
     fluff_builder.DestroyFluff();
 }
开发者ID:mattgor123,项目名称:CS355-Robo-Clean-5000,代码行数:12,代码来源:BroodmotherLair.cs

示例8: Awake

 void Awake()
 {
     playerInstance = Instantiate(player, spawn_point, Quaternion.identity) as GameObject;
     health_controller = playerInstance.GetComponent<HealthController>();
     var hudInstance = Instantiate(hud) as GameObject;
     var cameraInstance = Instantiate(camera, camera.transform.position, camera.transform.rotation) as GameObject;
     BuildGridAndRooms();
     StageBuilder.scale = scale;
     stage = new Stage(loadedGrid, loadedRooms, fluff_builder);
     stage.Create();
 }
开发者ID:mattgor123,项目名称:CS355-Robo-Clean-5000,代码行数:11,代码来源:TutorialController.cs

示例9: Can_call_delayed_call

 public void Can_call_delayed_call()
 {
     var stage = new Stage();
     var adder = stage.Create<IAdder>().Proxy;
     var t1 = adder.AddDelayed(1, 1, TimeSpan.FromSeconds(1));
     var sw = Stopwatch.StartNew();
     t1.Wait();
     sw.Stop();
     Assert.AreEqual(2, t1.Result);
     Assert.GreaterOrEqual(sw.ElapsedMilliseconds, 900);
 }
开发者ID:sdether,项目名称:Calculon,代码行数:11,代码来源:StageTests.cs

示例10: Can_find_actor_by_ref

 public void Can_find_actor_by_ref()
 {
     var stage = new Stage();
     var tester = stage.Create<IContextTester>().Proxy;
     var r = tester.Can_find_actor_by_ref().WaitForResult();
     var a1Id = r[0];
     var a2Id = r[1];
     var b1Id = r[2];
     var b2Id = r[3];
     Assert.AreNotEqual(a1Id, b1Id, "actor ids were the same");
     Assert.AreEqual(a1Id, a2Id, "a ids did not match");
     Assert.AreEqual(b1Id, b2Id, "b ids did not match");
 }
开发者ID:sdether,项目名称:Calculon,代码行数:13,代码来源:ActorContextTests.cs

示例11: Actors_do_not_share_state

        public void Actors_do_not_share_state()
        {
            var stage = new Stage();
            var a1 = stage.Create<ICounter>().Proxy;
            var a2 = stage.Create<ICounter>().Proxy;

            var a1Tasks = Enumerable.Range(0, 10).Select(x => a1.Increment()).ToArray();
            var a2Tasks = Enumerable.Range(0, 5).Select(x => a2.Increment()).ToArray();
            Task.WaitAll(a1Tasks);
            Console.WriteLine("a1 increments done");
            Task.WaitAll(a2Tasks);
            Console.WriteLine("a2 increments done");
            var a1Current = a1.Current();
            var a2Current = a2.Current();
            a1Current.Wait();
            Console.WriteLine("a1 current done");
            a2Current.Wait();
            Console.WriteLine("a2 current done");

            Assert.AreEqual(10, a1Current.Result);
            Assert.AreEqual(5, a2Current.Result);
        }
开发者ID:sdether,项目名称:Calculon,代码行数:22,代码来源:ActorStateTests.cs

示例12: Can_make_many_sequential_calls

        public void Can_make_many_sequential_calls()
        {
            var stage = new Stage();
            var a1 = stage.Create<IAdder>().Proxy;

            var a1Tasks = Enumerable.Range(0, 10).Select(x => a1.Add(x, 10)).ToArray();
            Console.WriteLine("all tasks started");
            Task.WaitAll(a1Tasks);
            Console.WriteLine("all tasks completed");
            for(var i = 0; i < 10; i++) {
                Assert.AreEqual(10 + i, a1Tasks[i].Result);

            }
        }
开发者ID:sdether,项目名称:Calculon,代码行数:14,代码来源:ActorConcurrencyTests.cs

示例13: FireAndForgetThroughput

 public void FireAndForgetThroughput()
 {
     var stage = new Stage();
     var a = stage.Create<IPerf>().Proxy;
     var n = 50000;
     var t = Stopwatch.StartNew();
     var tx = a.SignalCounter(n).ContinueWith(_ => t.Stop());
     for(var i = 0; i < n; i++) {
         a.Increment();
     }
     tx.Wait();
     t.Stop();
     Console.WriteLine("rate: {0:0.00}calls/s", n / t.Elapsed.TotalSeconds);
 }
开发者ID:sdether,项目名称:Calculon,代码行数:14,代码来源:MessagingPerfTests.cs

示例14: Can_find_actor_by_ref

        public void Can_find_actor_by_ref()
        {
            var stage = new Stage();
            var a1 = stage.Create<IIdentity>();
            var b1 = stage.Create<IIdentity>();
            var a2 = stage.Find<IIdentity>(a1.Ref);
            var b2 = stage.Find<IIdentity>(b1.Ref);
            var a1Id = a1.Proxy.GetIdentity().WaitForResult();
            var a2Id = a2.Proxy.GetIdentity().WaitForResult();
            var b1Id = b1.Proxy.GetIdentity().WaitForResult();
            var b2Id = b2.Proxy.GetIdentity().WaitForResult();

            Assert.AreNotEqual(a1Id,b1Id,"actor ids were the same");
            Assert.AreEqual(a1Id, a2Id, "a ids did not match");
            Assert.AreEqual(b1Id, b2Id, "b ids did not match");
        }
开发者ID:sdether,项目名称:Calculon,代码行数:16,代码来源:StageTests.cs

示例15: Exception_in_void_method_does_not_disable_actor

 public void Exception_in_void_method_does_not_disable_actor()
 {
     var stage = new Stage();
     var a = stage.Create<IFailing>().Proxy;
     a.VoidFailure();
     a.VoidFailure();
     var count = a.VoidFailureCalls().WaitForResult();
     Assert.AreEqual(2, count);
 }
开发者ID:sdether,项目名称:Calculon,代码行数:9,代码来源:ActorFailureTests.cs


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