Exemplo n.º 1
0
 public abstract void doCommand(CommThreadTest ctt);
Exemplo n.º 2
0
 public override void doCommand(CommThreadTest ctt)
 {
     ctt.message3();
 }
Exemplo n.º 3
0
        public static void Main()
        {
            bool endThread = false;
            CommThreadTest ctt = new CommThreadTest();
            Thread ctt_thread = new Thread(new ThreadStart(ctt.Run));
            ctt_thread.Start();
            string inp;

            // start the sub thread..
            while (!endThread)
            {

                Console.WriteLine("MAIN thread({0}) working...",Thread.CurrentThread.GetHashCode());
                Console.Write("input:");
                inp = Console.ReadLine();
                if (inp[0] == '1')
                {
                    ctt.SendMessage(new CommThreadTest.ctt_message1());
                }
                if (inp[0] == '2')
                {
                    ctt.SendMessage(new CommThreadTest.ctt_message2());
                }
                if (inp[0] == '3')
                {
                    ctt.SendMessage(new CommThreadTest.ctt_message3());
                }
                if (inp[0] == '4')
                {
                    ctt.SendMessage(new CommThreadTest.ctt_message1());
                    ctt.SendMessage(new CommThreadTest.ctt_message2());
                    ctt.SendMessage(new CommThreadTest.ctt_message3()); 
                }
                // 'stop'/'exit'/'quit'
                if (inp[0] == 's' || inp[0] == 'x' || inp[0] == 'q')
                {
                    ctt.StopThread = true;
                    endThread = true;
                }

            }
            while (ctt_thread.IsAlive)
            {
                Console.WriteLine("MAIN thread({0}) waiting on sub-thread...",Thread.CurrentThread.GetHashCode());
            }

        }