Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("[enter] to start grid application ...");
            Console.ReadLine();

            // create grid application
            ga = new GApplication(new GConnection("localhost", 9000, "user", "user"));
            ga.ApplicationName = "Alchemi Tutorial - Alchemi sample";

            // add GridThread module (this executable) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(MultiplierThread).Module));

            // create and add 10 threads to the application
            for (int i = 0; i < 10; i++)
            {
                // create thread
                MultiplierThread thread = new MultiplierThread(i, i + 1);

                // add thread to application
                ga.Threads.Add(thread);
            }

            // subscribe to events
            ga.ThreadFinish      += new GThreadFinish(ThreadFinished);
            ga.ThreadFailed      += new GThreadFailed(ThreadFailed);
            ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

            // start application
            ga.Start();

            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("[enter] to start grid application ...");
            Console.ReadLine();

            // create grid application
            ga = new GApplication(new GConnection("localhost", 9000, "user", "user"));
            ga.ApplicationName = "Alchemi Tutorial - Alchemi sample";

            // add GridThread module (this executable) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(MultiplierThread).Module));

            // create and add 10 threads to the application
            for (int i = 0; i < 10; i++)
            {
                // create thread
                MultiplierThread thread = new MultiplierThread(i, i + 1);

                // add thread to application
                ga.Threads.Add(thread);
            }

            // subscribe to events
            ga.ThreadFinish += new GThreadFinish(ThreadFinished);
            ga.ThreadFailed += new GThreadFailed(ThreadFailed);
            ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

            // start application
            ga.Start();

            Console.ReadLine();
        }
Exemplo n.º 3
0
        static void ThreadFinished(GThread th)
        {
            // cast GThread back to MultiplierThread
            MultiplierThread thread = (MultiplierThread)th;

            Console.WriteLine(
                "thread # {0} finished with result '{1}'",
                thread.Id,
                thread.Result);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("[enter] to start grid application ....");
            Console.ReadLine();

            // create grid application
            ga = new GApplication(new GConnection("localhost", 80, "user", "user"));
            ga.ApplicationName = "Alchemi Tutorial - Alchemi sample";

            // add GridThread module (this executable) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(MultiplierThread).Module));

            System.Console.WriteLine("successfully connected to manager and now going to start thread...");

            string I = "Hello";

            while (true)
            {
                flag = false;

                int i;
                for (i = 0; i < 100; i++)
                {
                    System.Console.Write("\nYour Query/You say: ");
                    I = System.Console.ReadLine();

                    //check for break signal
                    if ((I.ToLower() == "quit") || (I.ToLower() == "exit"))
                    {
                        break;
                    }

                    // create thread
                    MultiplierThread thread = new MultiplierThread(I);

                    // add thread to application
                    ga.Threads.Add(thread);
                }

                // subscribe to events
                ga.ThreadFinish      += new GThreadFinish(ThreadFinished);
                ga.ThreadFailed      += new GThreadFailed(ThreadFailed);
                ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

                // start application
                ga.Start();

                break;
                while (!flag)
                {
                    //do nothing but wait...
                }
            }
            Console.ReadLine();
        }
Exemplo n.º 5
0
        static void ThreadFinished(GThread th)
        {
            // cast GThread back to MultiplierThread
            MultiplierThread thread = (MultiplierThread)th;

            Console.WriteLine("Bot Response/Bot says: " + thread.Result);
            Console.WriteLine(
                "                 >> thread # {0} finished.\n",
                thread.Id);
            flag = true;
            //Main(new string[] { "" });
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("[enter] to start grid application ...");
            Console.ReadLine();

            // create standard grid connection
            GConnection gc = new GConnection("localhost", 9000, "user", "user");

            // create multi-use grid application
            ga = new GApplication(true);
            ga.ApplicationName = "Tutorial OTF - Alchemi sample";

            // use standard grid connection
            ga.Connection = gc;

            // add GridThread module (this executable) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(MultiplierThread).Module));

            // set the thread finish callback method
            ga.ThreadFinish += new GThreadFinish(ThreadFinished);

            // start application
            ga.Start();

            int    i     = -1;
            string input = "";

            while (input != "x")
            {
                i++;
                // create thread
                MultiplierThread thread = new MultiplierThread(i, i + 1);

                // add thread to application
                ga.StartThread(thread);

                Console.WriteLine("[enter] to start a new thread, [x] + [enter] to stop");
                input = Console.ReadLine();
            }

            ga.Stop();

            ApplicationStopped();
            Console.ReadLine();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Console.WriteLine("[enter] to start grid application ...");
            Console.ReadLine();

            // create standard grid connection
            GConnection gc = new GConnection("localhost", 9000, "user", "user");

            // create multi-use grid application
            ga = new GApplication(true);
            ga.ApplicationName = "Tutorial OTF - Alchemi sample";

            // use standard grid connection
            ga.Connection = gc;

            // add GridThread module (this executable) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(MultiplierThread).Module));

            // set the thread finish callback method
            ga.ThreadFinish += new GThreadFinish(ThreadFinished);

            // start application
            ga.Start();

            int i = -1;
            string input = "";

            while (input != "x")
            {
                i++;
                // create thread
                MultiplierThread thread = new MultiplierThread(i, i + 1);

                // add thread to application
                ga.StartThread(thread);

                Console.WriteLine("[enter] to start a new thread, [x] + [enter] to stop");
                input = Console.ReadLine();
            }

            ga.Stop();

            ApplicationStopped();
            Console.ReadLine();
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            Console.WriteLine("[enter] to start grid application ....");
            Console.ReadLine();

            // create grid application
            ga = new GApplication(new GConnection("localhost", 80, "user", "user"));
            ga.ApplicationName = "Alchemi Tutorial - Alchemi sample";

            // add GridThread module (this executable) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(MultiplierThread).Module));

            System.Console.WriteLine("successfully connected to manager and now going to start thread...");

            string I="Hello";
            while (true)
            {
                flag = false;

                int i;
                for (i = 0; i < 100; i++)
                {
                    System.Console.Write("\nYour Query/You say: ");
                    I = System.Console.ReadLine();

                    //check for break signal
                    if ((I.ToLower() == "quit") || (I.ToLower() == "exit"))
                        break;

                    // create thread
                    MultiplierThread thread = new MultiplierThread(I);

                    // add thread to application
                    ga.Threads.Add(thread);

                }

                // subscribe to events
                ga.ThreadFinish += new GThreadFinish(ThreadFinished);
                ga.ThreadFailed += new GThreadFailed(ThreadFailed);
                ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

                // start application
                ga.Start();

                break;
                while (!flag)
                {
                    //do nothing but wait...
                }
            }
            Console.ReadLine();
        }