473,396 Members | 1,774 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,396 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 15850
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.