threadabortexception

“Thread was being aborted” exception raised in excuting Hangfire job

有些话、适合烂在心里 提交于 2019-12-25 00:17:22
问题 I have a Hangfire (with SqlServer for persistence) job which query some data from database. Then generate an Excel with NPOI with these data, and sent it via Email to users. The data is not so large, only like 1,000 rows. So the job executes in seconds. However, I get "Thread was being aborted" exception when generating Excel or sending mail. I guess there is something like Timeout, which kills the thread. Does anyone have the same issue? Any solutions? 回答1: Alright. Actually I made a stupid

LegacyUnhandledExceptionPolicy doesn't allow to catch (and swallow) ThreadAbortException?

情到浓时终转凉″ 提交于 2019-12-23 15:52:09
问题 I'm using .NET 1.1 compability mode for unhandled exception handling. The problem is that when LegacyUnhandledExceptionPolicy is set to "1" (which is what I want), I cannot catch and swallow ThreadAbortException. Example code: App.config: <configuration> <runtime> <legacyUnhandledExceptionPolicy enabled="1"/> </runtime> </configuration> Code: class Program { static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += _onBackgroundThreadCrash; var t = new Thread(_worker) {

What happens with ASP.Net thread after Response.End ThreadAbortException?

落爺英雄遲暮 提交于 2019-12-07 15:52:15
问题 There are a few answers explaining Is Response.End() considered harmful? However I haven't find a clear confirmation, what would happen with ASP.Net thread after Response.End ThreadAbortException. Eric Lippert in his comment to Response.End () doesn't abort current thread noted that "thread is just going to go back in the thread pool.", but he admitted, that he had not worked on the threading model for more than 10 years. In CodeProject article Exploration of approaches to handle

Why is a finally block *sometimes* not executed on ThreadAbortException if it contains an await?

自作多情 提交于 2019-12-05 01:55:54
问题 UPDATE: I don't think this question is a duplicate of Can ThreadAbortException skip finally? because (1) I'm not creating another thread, so there's no possibility of a race condition, and (2) this behavior only occurs if the finally block contains an await , which that other question doesn't mention. Consider this console program: class Program { static void Main() { try { T().GetAwaiter().GetResult(); } catch (ThreadAbortException) { Thread.ResetAbort(); } catch { } } static async Task

Why is a finally block *sometimes* not executed on ThreadAbortException if it contains an await?

こ雲淡風輕ζ 提交于 2019-12-03 16:26:41
UPDATE: I don't think this question is a duplicate of Can ThreadAbortException skip finally? because (1) I'm not creating another thread, so there's no possibility of a race condition, and (2) this behavior only occurs if the finally block contains an await , which that other question doesn't mention. Consider this console program: class Program { static void Main() { try { T().GetAwaiter().GetResult(); } catch (ThreadAbortException) { Thread.ResetAbort(); } catch { } } static async Task Abort() { //await Task.Delay(1); // A Thread.CurrentThread.Abort(); // B } static async Task T() { try {

Can this unexpected behavior of PrepareConstrainedRegions and Thread.Abort be explained?

安稳与你 提交于 2019-11-30 21:31:48
I was playing around with Constrained Execution Regions tonight to better round out my understanding of the finer details. I have used them on occasion before, but in those cases I mostly adhered strictly to established patterns. Anyway, I noticed something peculiar that I cannot quite explain. Consider the following code. Note, I targeted .NET 4.5 and I tested it with a Release build without the debugger attached. public class Program { public static void Main(string[] args) { bool toggle = false; bool didfinally = false; var thread = new Thread( () => { Console.WriteLine("running");

Thread.Abort in ASP.NET app causes w3wp.exe to crash

三世轮回 提交于 2019-11-30 07:15:44
Please do not set duplicate flag on this qustion - it is not about "why ThreadAbortException occurs", it is about "why w3wp.exe process terminates after ThreadAbortException". Let's say we have simple web application with following code sample: protected void Page_Load(object sender, EventArgs e) { Response.Redirect("http://google.com"); } Which by fact means something like (see Is Response.End() considered harmful? ): protected void Page_Load(object sender, EventArgs e) { ...response write some data... System.Threading.Thread.CurrentThread.Abort(); } On my machine (Windows 10 Pro + IIS) this

Can this unexpected behavior of PrepareConstrainedRegions and Thread.Abort be explained?

谁说我不能喝 提交于 2019-11-30 05:39:15
问题 I was playing around with Constrained Execution Regions tonight to better round out my understanding of the finer details. I have used them on occasion before, but in those cases I mostly adhered strictly to established patterns. Anyway, I noticed something peculiar that I cannot quite explain. Consider the following code. Note, I targeted .NET 4.5 and I tested it with a Release build without the debugger attached. public class Program { public static void Main(string[] args) { bool toggle =

Thread.Abort doesn't seem to throw a ThreadAbortException because of AcceptSocket

拥有回忆 提交于 2019-11-29 15:10:53
I am calling ChannelServer.ListeningThread.Abort on the following thread, however nothing seems to happen. I would like to be more specific, but I can't think of anything more. There seems to be no ThreadAbortException that is thrown, and this exception should be thrown regardless of the blocking listener (it works perfectly on threads that are blockingly-receiving). Important EDIT : With a ManualResetEvent.WaitOne instead of AcceptSocket , as Lyrik has suggested for testing, it works perfectly. How come AcceptSocket blocks the ThreadAbortException ? LINK : This forum thread seems to discuss

Thread.Abort in ASP.NET app causes w3wp.exe to crash

非 Y 不嫁゛ 提交于 2019-11-29 09:23:50
问题 Please do not set duplicate flag on this qustion - it is not about "why ThreadAbortException occurs", it is about "why w3wp.exe process terminates after ThreadAbortException". Let's say we have simple web application with following code sample: protected void Page_Load(object sender, EventArgs e) { Response.Redirect("http://google.com"); } Which by fact means something like (see Is Response.End() considered harmful?): protected void Page_Load(object sender, EventArgs e) { ...response write