本文整理汇总了C#中ActorSystem.RestartActor方法的典型用法代码示例。如果您正苦于以下问题:C# ActorSystem.RestartActor方法的具体用法?C# ActorSystem.RestartActor怎么用?C# ActorSystem.RestartActor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActorSystem
的用法示例。
在下文中一共展示了ActorSystem.RestartActor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostRestartErrTest
public void PostRestartErrTest()
{
Exception e = null;
var acts = new ActorSystem();
var act = acts.CreateActor<RestartFaultActor>();
try
{
acts.RestartActor(act);
}
catch (Exception ex) { e = ex; }
Assert.IsNotNull(e);
}
示例2: PostRestartTest
public void PostRestartTest()
{
var acts = new ActorSystem();
var act = acts.CreateActor<IntoTestActor>();
var tsk = act.Ask<int>(new statemsg());
tsk.Wait();
Assert.AreEqual(10, tsk.Result);
acts.RestartActor(act);
tsk = act.Ask<int>(new statemsg());
tsk.Wait();
Assert.AreEqual(15, tsk.Result);
}
示例3: SimpleTestRestartActor
public void SimpleTestRestartActor()
{
var acts = new ActorSystem();
var act = acts.CreateActor<SimpleTestActor>();
var m = new statemsg() { newstate = 10 };
var tsk = act.Ask<int>(m);
tsk.Wait();
m = new statemsg() { newstate = 10 };
tsk = act.Ask<int>(m);
tsk.Wait();
Assert.AreEqual(10, tsk.Result);
acts.RestartActor(act);
m = new statemsg() { newstate = 10 };
tsk = act.Ask<int>(m);
tsk.Wait();
Assert.AreEqual(0, tsk.Result);
Console.WriteLine("test complete");
}
示例4: ChildHasStopedOrRestartedOnlyByParent
public void ChildHasStopedOrRestartedOnlyByParent()
{
var actf = new ActorSystem();
var act1 = actf.CreateActor<IerarhyTestActorOvveride>();
var tsk = act1.Ask<ActorRef>(new createchildactormsg());
tsk.Wait();
var act2 = tsk.Result;
Assert.IsNotNull(act2);
bool f = false;
try
{
actf.StopActor(act2);
}
catch
{
f = true;
}
Assert.IsTrue(f);
f = false;
try
{
actf.RestartActor(act2);
}
catch
{
f = true;
}
Assert.IsTrue(f);
}
示例5: RestartParentWithUserPredRestartNotStoppingChilds
public void RestartParentWithUserPredRestartNotStoppingChilds()
{
var actf = new ActorSystem();
var act1 = actf.CreateActor<IerarhyTestActorOvveride>();
var tsk = act1.Ask<ActorRef>(new createchildactormsg());
tsk.Wait();
var act2 = tsk.Result;
Assert.IsNotNull(act2);
actf.RestartActor(act1);
bool f = false;
try
{
act1.Ask<int>(new acttestmsg()
{
act = () => { return 0; }
})
.Wait(100);
}
catch
{
f = true;
}
Assert.IsFalse(f);
f = false;
try
{
act2.Ask<int>(new acttestmsg()
{
act = () => { return 0; }
})
.Wait(100);
}
catch
{
f = true;
}
Assert.IsFalse(f);
}
示例6: PredRestartTest
public void PredRestartTest()
{
var actf = new ActorSystem();
var act = actf.CreateActor<PredRestartTestActor>();
var tsk = act.Ask<int>(new setstate() { x = 20 });
tsk.Wait();
tsk = act.Ask<int>(new getstate());
tsk.Wait();
Assert.AreEqual(20, tsk.Result);
int savestate = 0;
tsk = act.Ask<int>(new setpra()
{
pra = (state) =>
{
savestate = state;
}
});
tsk.Wait();
actf.RestartActor(act);
Assert.AreEqual(20, savestate);
tsk = act.Ask<int>(new getstate());
tsk.Wait();
Assert.AreEqual(0, tsk.Result);
}
示例7: FaultOnRestartStoppingActor
public void FaultOnRestartStoppingActor()
{
bool f = false;
var acts = new ActorSystem();
var act = acts.CreateActor<RestartFaultActor>();
try
{
acts.RestartActor(act);
}
catch { }
var tsk = act.Ask<int>(new acttestmsg() { act = () => { return 0; } });
try { tsk.Wait(); }
catch { f = true; }
Assert.IsTrue(f);
}