473,287 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Thread.Abort not really aborting thread.

Is there any way to force a thread to abort and really have it abort? I have
a thread that every once in a while gets hung to so I kill it. Problem is I
have a thread that every once in a while gets stuck (I'm working on why that
happens) and I want to kill it. I do a thread.abort and the status becomes
abortrequested but never actually goes through.

If it were an actual process I could kill it but there seems to be no real
kill for thread other than abort.

Any thoughts?

TIA - Jeff.
Jun 12 '07 #1
4 15843
Are you performing any interop on the thread? If the call stack is
waiting on an interop call, then the thread can not abort until the
unmanaged code completes.

I would concentrate more on finding out why the thread hangs, as
aborting is not really the optimal way to signal that a thread should finish
its work.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mufasa" <jb@nowhere.comwrote in message
news:e2**************@TK2MSFTNGP05.phx.gbl...
Is there any way to force a thread to abort and really have it abort? I
have a thread that every once in a while gets hung to so I kill it.
Problem is I have a thread that every once in a while gets stuck (I'm
working on why that happens) and I want to kill it. I do a thread.abort
and the status becomes abortrequested but never actually goes through.

If it were an actual process I could kill it but there seems to be no real
kill for thread other than abort.

Any thoughts?

TIA - Jeff.
Jun 12 '07 #2
I have a service that goes out and crawls the web. Apparently some pages are
prompting for user input, which obviously you can't do with a service, so
that the thread stops.

I'm using HttpWebResponse with a timeout of 30 seconds and keepalive =
false.

I already am checking for the timeout and that seems to work when the page
just doesn't load. But there are some pages that it seems to get stuck on
and I don't know why.

My thought is that if it takes to long to get the pages, I'll just abort it.

Any thoughts?

TIA - Jeff.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:7E**********************************@microsof t.com...
Are you performing any interop on the thread? If the call stack is
waiting on an interop call, then the thread can not abort until the
unmanaged code completes.

I would concentrate more on finding out why the thread hangs, as
aborting is not really the optimal way to signal that a thread should
finish its work.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mufasa" <jb@nowhere.comwrote in message
news:e2**************@TK2MSFTNGP05.phx.gbl...
>Is there any way to force a thread to abort and really have it abort? I
have a thread that every once in a while gets hung to so I kill it.
Problem is I have a thread that every once in a while gets stuck (I'm
working on why that happens) and I want to kill it. I do a thread.abort
and the status becomes abortrequested but never actually goes through.

If it were an actual process I could kill it but there seems to be no
real kill for thread other than abort.

Any thoughts?

TIA - Jeff.

Jun 12 '07 #3
Jeff,

I doubt that the page is prompting for user input. When a page prompts
for user input, then that means that a JavaScript call, or embedded object
is asking for input. However, that requires the page to actually be
interpreted, which the HttpWebRequest/HttpWebResponse classes just don't do.

The timeout should work. Can you post an example of a timeout that
doesn't work?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mufasa" <jb@nowhere.comwrote in message
news:%2*****************@TK2MSFTNGP02.phx.gbl...
>I have a service that goes out and crawls the web. Apparently some pages
are prompting for user input, which obviously you can't do with a service,
so that the thread stops.

I'm using HttpWebResponse with a timeout of 30 seconds and keepalive =
false.

I already am checking for the timeout and that seems to work when the page
just doesn't load. But there are some pages that it seems to get stuck on
and I don't know why.

My thought is that if it takes to long to get the pages, I'll just abort
it.

Any thoughts?

TIA - Jeff.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:7E**********************************@microsof t.com...
> Are you performing any interop on the thread? If the call stack is
waiting on an interop call, then the thread can not abort until the
unmanaged code completes.

I would concentrate more on finding out why the thread hangs, as
aborting is not really the optimal way to signal that a thread should
finish its work.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mufasa" <jb@nowhere.comwrote in message
news:e2**************@TK2MSFTNGP05.phx.gbl...
>>Is there any way to force a thread to abort and really have it abort? I
have a thread that every once in a while gets hung to so I kill it.
Problem is I have a thread that every once in a while gets stuck (I'm
working on why that happens) and I want to kill it. I do a thread.abort
and the status becomes abortrequested but never actually goes through.

If it were an actual process I could kill it but there seems to be no
real kill for thread other than abort.

Any thoughts?

TIA - Jeff.


Jun 12 '07 #4

"Mufasa" <jb@nowhere.comwrote in message
news:e2**************@TK2MSFTNGP05.phx.gbl...
Is there any way to force a thread to abort and really have it abort? I
have a thread that every once in a while gets hung to so I kill it.
Problem is I have a thread that every once in a while gets stuck (I'm
working on why that happens) and I want to kill it. I do a thread.abort
and the status becomes abortrequested but never actually goes through.

If it were an actual process I could kill it but there seems to be no real
kill for thread other than abort.

Any thoughts?
Thread.Abort()

then follow it with

Thread.Join()

Jun 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: cottonviking | last post by:
Greetings, all! I've been pondering the pitfalls of aborting a secondary thread in a service app I'm writing (VB, fx v1.1). Everything I've read so far pretty much dissuades one from aborting one...
4
by: Stephan Steiner | last post by:
Hi I'm having some weird threading issues.. almost at random, if I dare change a line of my code, the shutdown sequence gets messed up. I'm using a thread to receive data from the network, that...
16
by: Bill | last post by:
Say I have a childThread currently is running a finally block to cleanup external resources. At the same time the main thread calls childThread.Abort(). The question is: when the...
7
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...
2
by: Xarky | last post by:
Hi, I am writing a small program, that makes use of threads. Now in on of the threads I have a critical section, where I am using the Monitor to handle this. *** Thread_1 *** started for(...)...
5
by: [Yosi] | last post by:
Why I can't abot a susspended thread. Who can terminat a thread imediatly without consider to its stat or execution?
1
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...
6
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...
20
by: =?ISO-8859-1?Q?Gerhard_H=E4ring?= | last post by:
John Dohn wrote: When I do this, I put a special value in the queue (like None) and in the worker thread, check for the special value and exit if found. Threads can also be marked as "daemon...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.