コード例 #1
0
ファイル: InitTest.cs プロジェクト: eryeer/AkkaTest
 public static void Init()
 {
     using (var system = ActorSystem.Create("Actor-system"))
     {
         var    receiver = system.ActorOf(ReceiverActor.Props(), "actor-supervisor");
         string numStr   = "";
         while (true)
         {
             Console.WriteLine("enter the msg num");
             numStr = Console.ReadLine();
             if (numStr.Equals("q"))
             {
                 break;
             }
             else
             {
                 int num = int.Parse(numStr);
                 for (int i = 0; i < num; i++)
                 {
                     receiver.Tell(new Message(num));
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: InitTest.cs プロジェクト: eryeer/AkkaTest
 private static void InitMultiThread()
 {
     using (var system = ActorSystem.Create("Actor-system"))
     {
         receiver = system.ActorOf(ReceiverActor.Props(), "actor-supervisor");
         string numStr = "";
         Thread t1     = new Thread(new ParameterizedThreadStart(SendMsg))
         {
             IsBackground = true
         };
         Thread t2 = new Thread(new ParameterizedThreadStart(SendMsg))
         {
             IsBackground = true
         };
         while (true)
         {
             Console.WriteLine("enter the msg num");
             numStr = Console.ReadLine();
             if (numStr.Equals("q"))
             {
                 break;
             }
             else
             {
                 int num = int.Parse(numStr);
                 t1.Start(num);
                 t2.Start(num);
             }
         }
     }
 }