Example #1
0
        /// <summary>
        /// 启动线程的代码.
        ///
        ///
        /// 注意: 静态方法 与 普通方法 在多线程上的区别, 在于 普通方法 需要创建类的实例.
        /// </summary>
        public static void StartThread()
        {
            ThreadSample sample = new ThreadSample();
            ThreadStart  ts     = new ThreadStart(sample.ThreadFunc);

            Thread t = new Thread(ts);

            // 启动.
            t.Start();
        }
        /// <summary>
        /// 启动线程的代码.
        /// 
        /// 
        /// 注意: 静态方法 与 普通方法 在多线程上的区别, 在于 普通方法 需要创建类的实例.
        /// </summary>
        public static void StartThread()
        {

            ThreadSample sample = new ThreadSample();
            ThreadStart ts = new ThreadStart(sample.ThreadFunc);

            Thread t = new Thread(ts);

            // 启动.
            t.Start();
        }
Example #3
0
        /// <summary>
        /// 启动线程的代码
        /// </summary>
        public static void StartThreadWithParam(string param)
        {
            ThreadSample sample = new ThreadSample();

            // 这里是 与 不带参数的线程,执行的时候,区别的地方.
            ParameterizedThreadStart ts = new ParameterizedThreadStart(sample.ThreadFuncWithParam);

            Thread t = new Thread(ts);

            // 启动.
            t.Start(param);
        }