哪位高手可以给我详细解释C#中线程下这个列子。。

[复制链接]
查看11 | 回复2 | 2008-11-30 15:52:58 | 显示全部楼层 |阅读模式
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace Text
{

class BasicThreadApp

{

public static void ChildThreadCall()

{

Console.WriteLine("Child thread started.");

}

public static void Main(string[] args)

{

ThreadStart ChildRef = new ThreadStart(ChildThreadCall);

Console.WriteLine("Main - Creating Child thread.");



Thread ChildThread = new Thread(ChildRef );

ChildThread.Start();

Console.WriteLine("Main - Have requested the start of child thread.");

Console.ReadLine();

}

}
}
我不明白什么时候使用,为什么要带参数··· 哪个线程是先开始的··

回复

使用道具 举报

千问 | 2008-11-30 15:52:58 | 显示全部楼层
ThreadStart ChildRef = new ThreadStart(ChildThreadCall);这个只是申明一个委托..他的意思是线程启动后调用ChildThreadCall方法Thread ChildThread = new Thread(ChildRef ); 这个是申明一个线程,他必须要一个线程委托参数,也就是ThreadStart ChildThread.Start();这句话才是正式表明线程启动...
回复

使用道具 举报

千问 | 2008-11-30 15:52:58 | 显示全部楼层
http://msdn.microsoft.com/zh-cn/library/ms173178(VS.80).aspx...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行