Exemplo n.º 1
0
        static void print_04()
        {
            SideTask st = new SideTask(100);
            Thread   t1 = new Thread(st.KeepAlive2);

            t1.IsBackground = false;
            Console.WriteLine("Starting thread");
            t1.Start();

            Thread.Sleep(1000);

            Console.WriteLine("Interruping thread");
            t1.Interrupt();

            Console.WriteLine("Wating untill thread stops");
            t1.Join();

            Console.WriteLine("Finished");
        }
Exemplo n.º 2
0
        static void print_02()
        {
            SideTask st = new SideTask(100);
            Thread   t1 = new Thread(st.KeepAlive);

            t1.IsBackground = false;

            Console.WriteLine(t1.ThreadState);

            Console.WriteLine("Starting Thread....");
            t1.Start();

            Thread.Sleep(1000);
            Console.WriteLine(t1.ThreadState);
            Console.WriteLine("Aborting thread");
            t1.Abort();

            Console.WriteLine(t1.ThreadState);
            Console.WriteLine("Wating until thread Stop");
            t1.Join();
            Console.WriteLine(t1.ThreadState);
            Console.WriteLine("Finished");
        }