h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Simple Threading in C#.net

Today ,we will discuss about small threading program in C#.Net

using System;
using System.Threading;

class ThreadTest
{
    public void Run()
    {
        Console.WriteLine("Run Called");
        Thread.Sleep(10000);
    }

    public static void Main(String[] args)
    {
        ThreadTest b = new ThreadTest();
        Thread t = new Thread(new ThreadStart(b.Run));
        t.Start();

        Console.WriteLine("Thread 't' started.");
        Console.WriteLine("There is no telling when " +
                          "'Run' will be invoked. ");

        t.Join();

        Console.WriteLine("Thread 't' has ended.");
    }
}