С#. Foreground and Background threads

Foreground and background threads.

If background thread then application will not wait until it is over, in other case it will.

        static void Main(string[] args)
        {
           
           var otherThread = new Thread(ThreadWorker);
           otherThread.IsBackground = false; // by default it is false
           otherThread.Start();
           Console.WriteLine("finish");
        }

        private static void ThreadWorker()
        {
            Thread.Sleep(1000);
            Console.WriteLine("inside other thread");
        }
This entry was posted in Без рубрики. Bookmark the permalink.