ParameterizedThreadStart(构造函数带参数的Thread)(方法之一)

    public delegate void ParameterizedThreadStart(object obj);
    class Work
    {
        public static Thread newThread = null;//Udp接收数据线程
        public static void Main()
        {
            Work w = new Work();
            w.threading();
        }
        public void threading()
        {
            newThread = new Thread(DoWork);
            newThread.Start(42);

            // Start a thread that calls a parameterized instance method.
            newThread = new Thread(DoMoreWork);
            newThread.Start("The answer.");
        }
        public List<byte> receiveBufferList = new List<byte>();  //UDP接收数据缓存

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

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

 

你可能感兴趣的:(ParameterizedThreadStart(构造函数带参数的Thread)(方法之一))