472,985 Members | 2,697 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,985 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 15819
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
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.