读书人

C#给线程传接参数

发布时间: 2012-08-31 12:55:03 作者: rapoo

C#给线程传递参数

需要注意的是怎样给线程传递参数。

using System;using System.Collections.Generic;using System.Data.OleDb;using System.Diagnostics;using System.IO;using System.Text;using System.Threading;namespace Test{    public class Program{      public test(){        TestObject t = TestObject("sky素年锦时");        Thread thread = new Thread(hello);        thread.Start(t);            }                //线程执行的代码,o为传递的参数对象      public void hello(Object o){          Console.Out.WriteLine("Hello, this is " + o.name);      }    }    class TestObject{      public String name;      public TestObject(){        this.name= name;      }    }}
?

读书人网 >C#

热点推荐