like

Sunday, January 12, 2014

Foreground and Backgound Thread

using System;
using System.Threading;
namespace _4ThreadApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            //Thread objThread = new Thread(CallToPrintMethod);
            //objThread.Start();

            //All the 4 virtual cpu usesage by this application.[their are 4 blocks]
            for (int i = 0; i < 4; i++)
            {
                Thread objThread = new Thread(CallToPrintMethod);
               //Uncomment below line if you want to make this Foreground Thread to Background Thread for applicaiton.

                // objThread.IsBackground = true;
                objThread.Start();
            }
        }

        private static void CallToPrintMethod(object obj)
        {
            while (true)
            {
                Console.WriteLine("This is Testing for CPU usesage.");
            }
        }
    }
}

No comments:

Post a Comment