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?
14 1726
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.
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?
async mode? (im sorry i just started with threading)
and how would i cancel that isnt that just another thread?
Instead of killing this thread, you can just signal it to end, and create a new thread (e.g. from a thread pool). You might also want to limit the number of threads per single session.
So, "you should have regular checks" would mean you should raise some "end" flag (or AutoResetEvent or something) without explicitly aborting your previous thread, and make the thread ends itself when it gets the signal.
hmmm, but then the problem is that the start button triggers thread A
when thread A wants to abort and keeps in the query then it wont do much good if it spawns another thread. unless i can make that dynamic.
the query can take up to 10 minutes to process
10 minutes is a long time to wait for a customer, do you think you can somehow avoid a count query?
Also, making a column "NON NULL" might improve performance for COUNT(col_name), because apparently there should be less checks to do in that case (table metadata should already contain the count). Caching the indexes in memory (that should be a server tweak) should also improve performance. Or see if you can get rid of Count if possible.
If thread A is busy waiting for results, and you cannot abort it, then there is no reason to create another thread which will wait for the first thread to finish. Try to identify the exact point at which your thread A blocks, and then you will know what to do.
it usually hangs up at the queries, i have found out that i can cancel the query so i can try to interrupt it like that.
the count is essential since it sets the progressbar maximum value, this will show the user how far the (lengthy) progress is coming along.
i will try column [0] because collumn names could differ
the count is essential since it sets the progressbar maximum value
That is actually what I meant: I would give greater priority to speed than progressbar accuracy (I wouldn't call progressbar essential).
So, if you can get (for example) maximum ID number in your table (which should be much faster than Count), then you can display the progress bar which will update as you move along (even if you don't have some IDs in your table). And progress bar doesn't update while you are getting Count, anyway.
(I understood that Count is the slow query that's giving you the problems, but if other queries are slow also, then it's a different story)
The id numbers arent generated by the database itself, it is all a list of 4 to 8 generated numbers.
i cant make any changes to the database or the server though.
I have to agree with vekipeki here.
If given the choice between accurate statusbar, and having a task take 10minutes less, I would take the 10minutes less.
Most progressbars are just a "guess" anyway.
When I use them, I move them by task, not weight of task.
Like if I have 10 things that need to be done, completeing a task moves the bar 1/10 of the way. Regardless of if one task is very simple and another is very complex.
then it will be no statusbar at all, its just a reader that merges databases... since the amount of records may change a fixed number isnt going to help that much either...
Sounds good. I would recomend a splash screen of sorts that says like "Merging Databases" and if you have it available, everytime a task finishes(or starts) just throw that up on the splash.
"Merging Datasbase: (tablename)"
.
.
.
"Merging Datasbase: (Some ofther tablename)"
i do have something like
"reading row"
"getting parent for <ID>"
and i like having the overview of "completeness" since it can give a little bit of insight on how long it might take.
however i have been told the server used is poo though, so it might as well be that. some other times the query gets through in < 20 seconds...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Daisy |
last post by:
From this page:
http://www.c-sharpcorner.com/2/mt_beginner1.asp
Thread class's Abort method is called to kill a thread permanently. Make
sure you call IsAlive before Abort.
if (...
|
by: Morris |
last post by:
I want to abort a running thread, so I call MyThread.abort() function. My problem is this thread runs "almost" like a while(true) loop and I don't want the Abort() function interrupts the thread at...
|
by: Doug Thews |
last post by:
I ran into an interesting re-pain delay after calling the Abort() method on
a thread, but it only happens the very first time I call it. Every time
afterward, there is no delay.
I've got a...
|
by: Urs Vogel |
last post by:
Hi
I wrote an application server (a remoting sinlgeton), where processes must
be stopped in very rare cases, done thru a Thread.Abort(). Occasionally, and
only after a Thread.Abort(), this...
|
by: benmorganpowell |
last post by:
I have a small windows service which connects to a POP3 server at
defined intervals, scans the available messages, extracts the required
information and inserts the data into a SQL database. I am...
|
by: Joe HM |
last post by:
Hello -
I have a function that calls Thread.Abort() to stop a thread in a
_Closed() Method of a GUI. The thread contains a blocking call on a
TCP socket and that is the easiest way to stop...
|
by: Boltar |
last post by:
Hi
I'm writing a threading class using posix threads on unix with each
thread being run by an object instance. One thing I'm not sure about
is , if I do the following:
myclass::~myclass()
{...
|
by: andrew |
last post by:
Hi,
I have the following issue with the Thread.Abort():
The main thread creates a worker thread which waits on a process
termination.
void ThreadProc()
{
Process proc =...
|
by: mehdi |
last post by:
Hi folks,
You know, the Thread class has got a method named Abort which
according to the msdn:
"Raises a ThreadAbortException in the thread on which it is invoked,
to begin the process of...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |