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