[DotNet]Run A New Thread(Use Lambda Expression)

Thread class:

    public static void ThreadProc() {
        for (int i = 0; i < 10; i++) {
             Console.WriteLine("ThreadProc: {0}", i);
             Thread.Sleep(10);
        }
    }

    public static void DoWork(object data) {
            Console.WriteLine("Static thread procedure. Data='{0}'",data);
    }

   

    Thread t = new Thread(new ThreadStart(ThreadProc));
   
Thread parameterThread = new Thread(DoWork);
    t.Start();
    t.Abort();

ThreadPool Class:

Result:

Dispatcher class:

ThreadStart methodDelegate = delegate() {

Dispatcher.Invoke(new Action(FillContactsTree), null);

};

Thread t = new Thread(methodDelegate);

t.Start();

 

 

blog comments powered by Disqus