线程初识,为什么Abort()了不能再start

这篇博客记录了作者在学习线程知识时遇到的问题:在使用Thread.Abort停止线程后,无法再次启动线程。通过谷歌搜索,作者发现线程结束后需要重新创建才能正常运行,并提供了修改后的代码示例。
摘要由CSDN通过智能技术生成

2011-03-22

今天第一天学习线程知识,顺便来做下笔记~~

以下是代码:

using System;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private Thread thread1 = new Thread(new ThreadStart(FormShow1));

 

        public Form1()
        {
            InitializeComponent();
        }

        private void Threa1Start_Click(object sender, EventArgs e)
        {
            thread1.Start();
            buttom();
            textBox1.Text += "thread1.IsAlive:" + thread1.IsAlive + "/r/n";
        }

        private void Threa1Stop_Click(object sender, EventArgs e)
        {
            thread1.Abort();
            thread1.Join();
            FormShowStop1();
            buttom();
        

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值