如何杀死线程 [英] How to Kill thread

查看:91
本文介绍了如何杀死线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想杀死或停止在for循环中运行的线程.
在for循环中,我正在将记录插入数据库.一旦单击中止",它应该停止操作.

谢谢
sjs

Hi,

I want to kill or stop the thread which is running in for loop.
In for loop I''m inserting records into the database. Once I click on Abort it should stop the operation.

Thanks
sjs

推荐答案

这个问题是贴错标签的,或者是白痴的. ASP.NET网站不应使用线程,因为当页面生命周期结束时,您的子线程将被孤立.
This question is either mis tagged, or idiotic. An ASP.NET website should not use threading, because your sub thread will be orphaned when your page lifecycle ends.


您好,sjs4u,

只需调用Abort方法即可.

System.Threading.Thread线程;

//一个事件
thread = new Thread(new ThreadStrart(Function Call));
thread.Start();

//另一个事件(这是您的停止操作)
thread.Abort();

我认为这对您有帮助.

谢谢:)
Hi sjs4u,

Just you call Abort method.

System.Threading.Thread thread;

//One Event
thread=new Thread(new ThreadStrart(Function Call));
thread.Start();

//Another Event (Its your stop Operation)
thread.Abort();

I think its helpful to you.

Thanks :)


这篇关于如何杀死线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆