码迷,mamicode.com
首页 > 编程语言 > 详细

C# 多线程,new ThreadStart(方法)中的方法如果有参数,该怎么写

时间:2014-12-30 16:43:54      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Threading;

public class Work
{
    public static void Main()
    {
        // Start a thread that calls a parameterized static method.
        Thread newThread = new Thread(Work.DoWork);
        newThread.Start(42);

        // Start a thread that calls a parameterized instance method.
        Work w = new Work();
        newThread = new Thread(w.DoMoreWork);
        newThread.Start("The answer.");
    }

    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);
    }
}

C# 多线程,new ThreadStart(方法)中的方法如果有参数,该怎么写

标签:

原文地址:http://www.cnblogs.com/yangjinwang/p/4193760.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!