本文整理汇总了C#中System.Threading.Thread.Thread构造函数的典型用法代码示例。如果您正苦于以下问题:C# Thread构造函数的具体用法?C# Thread怎么用?C# Thread使用的例子?那么恭喜您, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.Threading.Thread
的用法示例。
在下文中一共展示了Thread构造函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
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);
}
}
// This example displays output like the following:
// Static thread procedure. Data='42'
// Instance thread procedure. Data='The answer.'
开发者ID:.NET开发者,项目名称:System.Threading,代码行数:33,代码来源:Thread示例2: Main
//引入命名空间
using System;
using System.Threading;
class Test
{
static void Main()
{
Thread newThread =
new Thread(new ThreadStart(Work.DoWork));
newThread.Start();
}
}
class Work
{
Work() {}
public static void DoWork() {}
}
开发者ID:.NET开发者,项目名称:System.Threading,代码行数:20,代码来源:Thread示例3: Main
//引入命名空间
using System;
using System.Threading;
class Test
{
static void Main()
{
Work threadWork = new Work();
Thread newThread =
new Thread(new ThreadStart(threadWork.DoWork));
newThread.Start();
}
}
class Work
{
public Work() {}
public void DoWork() {}
}
开发者ID:.NET开发者,项目名称:System.Threading,代码行数:21,代码来源:Thread本文标签属性:
示例:示例志愿表
代码:代码生成器
Thread:threads