我又来了,关于线程里调用System.Thread.Timer计时器,但是结束线程,程序却还在运行.今天都用掉300分了,帮帮我,解决了在送分
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading;
namespace MyThread
{
public class TestThread
{
private System.Windows.Forms.Label label1;
private System.Threading.Thread timeThread;
public TestThread()
{
}
private void RunThread()
{
//这里开始线程
timeThread = new Thread(new ThreadStart(TestThreadTimer));
timeThread.Start();
}
private void StopThread()
{
//这里结束线程
timeThread.Abort();
//但是不能结束
}
public void TestThreadTimer()
{
System.Threading.Timer timer = new System.Threading.Timer(
new TimerCallback(this.TimerMethod),
null,
0,
500
);
}
public void TimerMethod(object state)
{
this.label1.Text = DateTime.Now.ToString();
}
}
}
//调用的timerThread不能结束,要用到线程池吗?
//线程里调用线程,如果强制结束调用线程,里面哪个线程也会结束吗?