Questions tagged [thread-abort]

Thread.Abort raises an exception in the thread on which it was invoked, to begin terminating the thread.

Thread.Abort raises a ThreadAbortException in the thread on which it was invoked, to begin terminating the thread.

References

64 questions
18
votes
5 answers

When an ASP.NET System.Web.HttpResponse.End() is called, the current thread is aborted?

when a System.Web.HttpResponse.End() is called a System.Thread.Abort is being fired, which i'm guessing is (or fires) an exception? I've got some logging and this is being listed in the log file... A first chance exception of type…
Pure.Krome
  • 78,923
  • 102
  • 356
  • 586
17
votes
2 answers

Thread aborted exceptions in wcf service

I have a WCF service (built in .NET framework 3.5) hosted on IIS 6.0. The flow of the code is as follows Client (which is another web service) calls the WCF service WCF services invokes a thread to do the processing in background and responds to…
shivkumar
  • 209
  • 1
  • 5
17
votes
5 answers

How does Thread.Abort() work?

We usually throw exception when invalid input is passed to a method or when a object is about to enter invalid state. Let's consider the following example private void SomeMethod(string value) { if(value == null) throw new…
Sriram Sakthivel
  • 67,773
  • 7
  • 96
  • 172
16
votes
2 answers

Thread abort leaves zombie transactions and broken SqlConnection

I feel like this behavior should not be happening. Here's the scenario: Start a long-running sql transaction. The thread that ran the sql command gets aborted (not by our code!) When the thread returns to managed code, the SqlConnection's state…
womp
  • 111,854
  • 24
  • 229
  • 262
7
votes
1 answer

Stopping a service that reads MSMQ

I'm a Java programmer who has been asked to make some changes to C# applications. I've been working with C# for a week now, and I've finally hit a point where looking at the documentation isn't helping and I can't find solutions when I google. In…
Mourdos
  • 223
  • 3
  • 10
6
votes
1 answer

SqlClient calls causing "Thread was being aborted at SNINativeMethodWrapper.SNIPacketGetConnection(IntPtr packet)"

I would really appreciate any suggestions, no matter how simple or complex, to help me get this issue isolated and resolved. I have a bit of code that generates small report files. For each file in the collection, a stored proc is executed to get…
StingyJack
  • 17,990
  • 7
  • 58
  • 115
6
votes
4 answers

How do I abort multiple threads?

In this code, when button1 is clicked twice, it creates 2 separate threads. On one click, it creates a new thread on the heap and field t1 points to the new thread on the heap. When I click button2, it aborts the last thread (which t1 refers to). …
maysam
  • 399
  • 8
  • 22
5
votes
8 answers

How do I suppress a thread.abort() error C#?

I am showing a splash screen on a background thread while my program loads. Once it loads I am aborting the Thread as it's only purpose was to show a Now Loading splash form. My problem is that when aborting a Thread it throws a…
Refracted Paladin
  • 11,636
  • 32
  • 115
  • 224
5
votes
1 answer

Aborting the thread from inside the same thread

I created a thread A and decided to abort it from inside the thread A. Is that possible? If so how can I do that? Thanks for the help!
Dilshod
  • 2,925
  • 2
  • 30
  • 62
5
votes
2 answers

what's the proper way to tell a thread that is executing a loop to break out of the loop and do something else?

The following code has the disadvantage that the worker thread will neither terminate immediately nor perform a final action after the main thread resets the waithandle. Instead, it will continue doing what it is doing until it reaches the next…
John Smith
  • 3,800
  • 5
  • 35
  • 55
4
votes
2 answers

How can I wake a sleeping thread in C#?

Before people suggest it: I am not using Thread.sleep for anything except trying to find a way to work around it. I am trying to handle other people's future code which may not be .Sleep() free. I have a very good grasp of how horrible it is for…
Groxx
  • 2,399
  • 1
  • 23
  • 32
4
votes
1 answer

ADO.Net Entity Framework Thread abort exception while reading the data

I am facing a strange issue while reading a data using ADO.Net Entity framework. I have two tables, "Surveys" and "PatientVists". "VisitId" is the primary key in "PatientVists" which is foreign key in "surveys" table. I am using following…
Amey
  • 976
  • 11
  • 25
4
votes
1 answer

Thread.Abort() vs Application.Exitthread()

I know Exitthread can only be called from within the Thread, and Abort can be used at anytime anywhere as long as you can access the Thread object. But are there other significant differences between these two methods (operation-wise) when you need…
Jordy
  • 1,796
  • 14
  • 29
3
votes
2 answers

Do static constructors run as CERs?

I'm testing the below code: private static void Main() { var t = new Thread(() => { var m = new MyCls(); m.DoWork(); }); t.Start(); // simulate time-consuming job Thread.Sleep(1000); t.Abort(); …
KeyBored
  • 601
  • 3
  • 13
3
votes
1 answer

Odd behavior: Catching ThreadAbortException and throwing different exception

As a result of investigating this question: Rethrowing exception in Task doesn't make the Task to go to faulted state, I noticed some very odd behavior with the ThreadAbortException that I can't make sense of. Now, I know that ThreadAbortException…
sstan
  • 32,273
  • 5
  • 41
  • 62
1
2 3 4 5