日期:2014-05-18 浏览次数:20923 次
public delegate void delegateHandle(object sender,EventArgs e); public partial class FCPMClient : Form { public event delegateHandle onFinished; private Thread thread = null; public FCPMClient() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { thread = new Thread(new ThreadStart(fun1)); thread.Start(); this.onFinished += new delegateHandle(fun2); } private void fun1(){ onFinished(this, new EventArgs()); } private void fun2(object sender, EventArgs e){ thread.Abort(); } }
public delegate void delegateHandle(); public partial class FCPMClient : Form { public event delegateHandle onFinished; public FCPMClient() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { thread = new Thread(new ThreadStart(fun1)); thread.Start(); label1.Text = "线程开始"; } private void fun1(){ Thread.Sleep(3000); onFinished mi = new onFinished(fun2); } private void fun2(){ label1.Text = "线程结束"; } }