本文整理汇总了C#中Akka.Actor.ActorRef.Ask方法的典型用法代码示例。如果您正苦于以下问题:C# ActorRef.Ask方法的具体用法?C# ActorRef.Ask怎么用?C# ActorRef.Ask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akka.Actor.ActorRef
的用法示例。
在下文中一共展示了ActorRef.Ask方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeathWatch_must_fail_a_monitor_which_doesnt_handle_Terminated
public void DeathWatch_must_fail_a_monitor_which_doesnt_handle_Terminated()
{
EventFilter.Exception<ActorKilledException>().And.Exception<DeathPactException>().Expect(2, () =>
{
var strategy = new FailedSupervisorStrategy(TestActor);
_supervisor = Sys.ActorOf(Props.Create(() => new Supervisor(strategy)).WithDeploy(Deploy.Local));
var failed = _supervisor.Ask(Props.Empty).Result as ActorRef;
var brother = _supervisor.Ask(Props.Create(() => new BrotherActor(failed))).Result as ActorRef;
StartWatching(brother);
failed.Tell(Kill.Instance);
var result = ReceiveWhile(TimeSpan.FromSeconds(5), msg =>
{
var res = 0;
msg.Match()
.With<FF>(ff =>
{
if (ff.Fail.Cause is ActorKilledException && ff.Fail.Child == failed) res = 1;
if (ff.Fail.Cause is DeathPactException && ff.Fail.Child == brother) res = 2;
})
.With<WrappedTerminated>(x => res = x.Terminated.ActorRef == brother ? 3 : 0);
return res.ToString();
}, 3);
((InternalActorRef)TestActor).IsTerminated.ShouldBe(false);
result.ShouldOnlyContainInOrder("1", "2", "3");
});
}
示例2: RouteeSize
private int RouteeSize(ActorRef router)
{
var routeesTask = router.Ask<Routees>(new GetRoutees(), TestKitSettings.DefaultTimeout);
routeesTask.Wait(TestKitSettings.DefaultTimeout);
return routeesTask.Result.Members.Count();
}