本文整理汇总了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();
}
示例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()
}
}
示例3: MemberRemoved
private async void MemberRemoved(ActorSystem actorSystem)
{
await actorSystem.Terminate();
asTerminatedEvent.Set();
}