如何取消长时间运行的数据库操作? [英] How to cancel a long-running Database operation?

查看:251
本文介绍了如何取消长时间运行的数据库操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前正在与甲骨文,但还需要对MS SQL的解决方案。

Currently working with Oracle, but will also need a solution for MS SQL.

我有一个图形用户界面,使用户能够生成将在数据库上执行的SQL。这可能需要很长的时间,这取决于它们所产生的搜索。我想在GUI /应用程序来响应这个搜索过程中,我希望用户能够取消搜索。

I have a GUI that allows users to generate SQL that will be executed on the database. This can take a very long time, depending on the search they generate. I want the GUI/App to responsive during this search and I want the user to be able to cancel the search.

我使用的是后台工作线程。

I'm using a Background Worker Thread.

我的问题是,当用户取消搜索,我不能中断调用数据库。它等待,直到它完成,然后,它可以轮询CancelationPending'属性。这不仅浪费资源的数据库,但它为我的code产生的问题。

My problem is that, when the user cancels the search, I can't interrupt the call to the database. It waits until it is finished and then, it can poll the 'CancelationPending' property. Not only does this waste resources on the database, but it creates problems for my code.

如果用户点击一个非常长的查询搜索,然后点击取消,然后点击搜索了 - 第一次搜索仍在隆隆而去数据库。后台工作人员还在忙碌着,当他们击中重新搜索。我有这个问题唯一的解决办法是让一个新的后台工作。

If the user hits 'Search' on a very long query, then clicks 'Cancel' and then 'Search' again - the first search is still chugging away on the database. The background worker is still busy when they hit search again. The only solution I've got to this problem is to make a new background worker.

这似乎是一个非常丑陋的方式来做事。该数据库保存工作我创建的背景工人的新实例....当我真正想停止数据库调用和重复使用同一个工作。

It seems like a really ugly way to do things. The database keeps working I'm creating new instances of background workers....when I really want to STOP the database call and re-use the same worker.

我怎么能这样做?

推荐答案

我不认为这是可能的。这里是一个链接到Oracle的网站上关于这个话题的讨论: 的http://forums.oracle.com/forums/thread.jspa?threadID=400492&start=15&tstart=0

I dont think it is possible. Here is a link to a discussion on Oracle's website about this topic: http://forums.oracle.com/forums/thread.jspa?threadID=400492&start=15&tstart=0

这篇关于如何取消长时间运行的数据库操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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