Пример #1
0
        private void DoSend(string msg)
        {
            int i = 0;
            IMsgQueue <IActor> item = fQueue.TryDequeue().Result;

            while (item.Result && (i < KSize))
            {
                item.Data.SendMessage("Bop");
                item = fQueue.TryDequeue().Result;
                Console.WriteLine("receive " + i.ToString(CultureInfo.InvariantCulture));
                i++;
            }
            Console.WriteLine("end " + i.ToString(CultureInfo.InvariantCulture));
        }
Пример #2
0
 public void TestActorQueue()
 {
     TestLauncherActor.Test(() =>
     {
         var actorqueue = new QueueActor <string>();
         actorqueue.Queue("a");
         actorqueue.Queue("b");
         actorqueue.Queue("c");
         var a = actorqueue.TryDequeue();
         var b = actorqueue.TryDequeue();
         var c = actorqueue.TryDequeue();
         Assert.IsTrue(a.Result.Result);
         Assert.IsTrue(b.Result.Result);
         Assert.IsTrue(c.Result.Result);
         string s = a.Result.Data + b.Result.Data + c.Result.Data;
         Assert.AreEqual(3, s.Length);
         Assert.IsTrue(s.Contains("a"));
         Assert.IsTrue(s.Contains("b"));
         Assert.IsTrue(s.Contains("c"));
     });
 }