Thread.Abort()不会触发 [英] Thread.Abort() not triggering

查看:184
本文介绍了Thread.Abort()不会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我搜索的范围很广,我发现数以百万计的帖子告诉BAD或你应该定期检查但这对我不起作用。


问题是,我有一个关于查询的程序。 thread.abort函数不会在查询中触发。现在这是一个慢速服务器上的冗长查询,只是使用超时不会工作因为那时我几乎永远不会得到查询。 (我估计20个中有3个)

但不耐烦的用户可能想要重击取消按钮并重试。


我想要的是杀死的线程。但仍然可以使用。再次,线程中止不是我的方式,因为我想在查询中杀死它。


任何方式这样做?

Hello,

I have searched far and wide, and i found millions of post telling "BAD" or "you should have regular checks" but that wont work for me.

the problem is, i have a program that is all about queries. the thread.abort function does not trigger in the middle of a query. now this is a lengthy query on a slow server, and just using timeout wont work because then i will almost never get the query. (3 out of 20 i estimate)
but the impatient users might want to bash a cancel button and retry.

what i want is the thread killed. but still usable. again, thread abort is not the way for me because i want to kill it mid-query.

any way to do this?

推荐答案

Thread.Abort()只是提升线程上的ThreadAborting异常,这意味着Thread必须转换才能处理消息。如果它忙于IO调用,它就不会收到消息直到它完成。
Thread.Abort() just raisies the ThreadAborting exception on the thread, which means the Thread has to be transitioning to process the message. If its busy with an IO call, it won''t get the message until its done.


啊,有没有什么方法可以立即将其删除?因为有时查询最多可能需要10分钟才能完成。它是一个相当大的数据库,我正在运行一个计数查询。
ah, well is there any way to just kill it off instantly? because sometimes the query can take up to 10 minutes to process. its a reasonably large database and im running a count query against it.


我认为有一种方法可以在异步模式下进行查询,你取消了这种方式吗?
I think there is a way to do the queries in async mode, and you cancel that way?


这篇关于Thread.Abort()不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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