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


C# ActorSystem.Terminate方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            #region DI things
            var builder = new ContainerBuilder();
            builder.RegisterType<NotificationAnalyzer>().As<INotificationAnalyzer>();
            builder.RegisterType<PushNotificationActor>();
            var container = builder.Build();
            #endregion

            NotificationsActorSystem = ActorSystem.Create("NotificationsActorSystem");
            IDependencyResolver resolver = new AutoFacDependencyResolver(container, NotificationsActorSystem);

            Props notificationActor = Props.Create<NotificationActor>();
            IActorRef pushNotificationActorRef = NotificationsActorSystem.ActorOf(notificationActor, "NotificationActor");

            Console.ReadKey();
            Console.WriteLine("Sending notification");

            pushNotificationActorRef.Tell(new NotificationMessage("[email protected]", "New Job"));

            //This is for reaching from lower level actor to high level actor

            //NotificationsActorSystem.ActorSelection("user/NotificationActor/PushNotificationActor")
            //    .Tell(new NotificationMessage("[email protected]", "New Job"));

            Console.ReadKey();

            NotificationsActorSystem.Terminate();
        }
开发者ID:otgcjm,项目名称:akkaPrototype,代码行数:29,代码来源:Program.cs

示例2: Shutdown

        /// <summary>
        /// Shuts down the specified system.
        /// On failure debug output will be logged about the remaining actors in the system.
        /// If verifySystemShutdown is true, then an exception will be thrown on failure.
        /// </summary>
        /// <param name="system">The system to shutdown.</param>
        /// <param name="duration">The duration to wait for shutdown. Default is 5 seconds multiplied with the config value "akka.test.timefactor"</param>
        /// <param name="verifySystemShutdown">if set to <c>true</c> an exception will be thrown on failure.</param>
        protected virtual void Shutdown(ActorSystem system, TimeSpan? duration = null, bool verifySystemShutdown = false)
        {
            if (system == null) system = _testState.System;

            var durationValue = duration.GetValueOrDefault(Dilated(TimeSpan.FromSeconds(5)).Min(TimeSpan.FromSeconds(10)));

            var wasShutdownDuringWait = system.Terminate().Wait(durationValue);
            if(!wasShutdownDuringWait)
            {
                const string msg = "Failed to stop [{0}] within [{1}] \n{2}";
                if(verifySystemShutdown)
                    throw new TimeoutException(string.Format(msg, system.Name, durationValue, ""));
                //TODO: replace "" with system.PrintTree()
                system.Log.Warning(msg, system.Name, durationValue, ""); //TODO: replace "" with system.PrintTree()
            }
        }
开发者ID:juergenhoetzel,项目名称:akka.net,代码行数:24,代码来源:TestKitBase.cs

示例3: MemberRemoved

 private async void MemberRemoved(ActorSystem actorSystem)
 {
     await actorSystem.Terminate();
     asTerminatedEvent.Set();
 }
开发者ID:ZoolWay,项目名称:akka-net-cluster-graceful-shutdown-samples,代码行数:5,代码来源:Worker.cs


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