Пример #1
0
        static void Main(string[] args)
        {
            SideTask task = new SideTask(1000);

            Thread th = new Thread(new ThreadStart(task.KeepAlive));

            th.IsBackground = false;

            WriteLine();

            th.Start();
            Thread.Sleep(100);
            th.Abort();
            th.Join();
        }
Пример #2
0
        static void Main(string[] args)
        {
            SideTask task = new SideTask(100);
            Thread   t1   = new Thread(new ThreadStart(task.KeepAlive));

            t1.IsBackground = false;

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

            Thread.Sleep(100);

            Console.WriteLine("Aborting thread...");
            t1.Abort();

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

            Console.WriteLine("Finished");
        }
Пример #3
0
        static void Main(string[] args)
        {
            SideTask task = new SideTask(1000);

            Thread th = new Thread(new ThreadStart(task.KeepAlive));

            th.IsBackground = false;        //true일 경우 background로 돌아감

            Console.WriteLine("Starting thread...");
            th.Start();

            Thread.Sleep(100);

            Console.WriteLine("Aborting thread...");
            th.Abort();

            Console.WriteLine("Wating until thread stop...");
            th.Join();

            Console.WriteLine("Done!!");
        }