Esempio n. 1
0
        static void Main(string[] args)
        {
            var fileName = args[0];
            // var space = new SequentialSpace();
            var treeSpace = new TreeSpace();

            try
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    string line;
                    int    i = 0;
                    while ((line = sr.ReadLine()) != null)
                    {
                        i++;
                        treeSpace.Put(line);
                    }
                    Console.WriteLine(i);
                    var resList = treeSpace.GetAll(typeof(string));
                    foreach (var res in resList)
                    {
                        Console.WriteLine(res[0]);
                    }
                }
            }
            catch (Exception e)
            {
                // Let the user know what went wrong.
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(1);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // Instantiate a new Fifobased tuplespace.
            ISpace pingpongTable = new TreeSpace();

            // Insert the ping.
            pingpongTable.Put("ping", 0);

            // Create two PingPong agents and start them.
            PingPong a1 = new PingPong("ping", "pong", pingpongTable);
            PingPong a2 = new PingPong("pong", "ping", pingpongTable);

            a1.Start();
            a2.Start();
            Console.Read();
        }