Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 182689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:59:01+00:00 2026-05-11T14:59:01+00:00

We are using an asynchronous HttpHandler in ASP.NET 3.5 under IIS 6, and in

  • 0

We are using an asynchronous HttpHandler in ASP.NET 3.5 under IIS 6, and in our code we’re wanting to perform an external API call if we’re not under too much load. We’ve defined ‘too much load’ meaning that if we have more than X requests hitting this API at the same time, we’ll just skip calling the API.

To accomplish this, we’ve wrapped our code in a Semaphore and Try/Catch/Finally. I feel like there’s no way for this code to execute without releasing the semaphore, but with some additional logging, we’re seeing that under heavy load the release statement is never being called.

The code is this:

static Semaphore requestLimiter = new Semaphore(500, 500);  ...  String GetResultFromAPI() {     if (!requestLimiter.WaitOne(0)) return null;      try     {         // ... code to perform API call, with a timeout specified on the HttpWebRequest         return result;     } catch { /* ignore exceptions */ }     finally     {         requestLimiter.Release();     }     return null; } 

We’ve seen the exceptions for when the HttpWebRequest does time out, so we’re puzzled as to how this code could result in the requestLimiter semaphore getting down to 0 and never recovering.

Has anyone encountered this? Is there any way an asynchronous HttpHandler can have a request interrupted without an exception?

Edit

Apparently ThreadAbortExceptions are a nasty beast that this code will definitely fail under. We aren’t explicitly calling Thread.Abort, nor do I think HttpWebRequest would. However, now the revised question is: does ASP.NET ever call Thread.Abort for asynchronous http requests?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:59:02+00:00Added an answer on May 11, 2026 at 2:59 pm

    IIS can shutdown a worker thread which would trigger a ThreadAbortException and ThreadAbortException’s are not always caught with finally. They are caught with catch though. I’ve had this problem when IIS kills a web request for whatever reason. My logging process would be spawned off in a new thread to log the error and the Thread.Abort would still kill my logging process. Even tried putting the logging thread spawn in the finally{} and IIS still kills it. I could never figure out how to solve it.

    Anyways, I would check your Event Viewer for recycled/killed worker threads and maybe check your application pool and make sure it is set to not recycle/restart often.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need ASP.NET MVC v1.0 Futures assembly: <%= Html.ActionLink<MyController>(x =>… May 12, 2026 at 12:56 am
  • Editorial Team
    Editorial Team added an answer A class to a varchar? I'm not aware of any… May 12, 2026 at 12:56 am
  • Editorial Team
    Editorial Team added an answer I would stick with the SystemFonts as that way the… May 12, 2026 at 12:56 am

Related Questions

What is the difference between Web Services Asynchronous Call and Asynchronous Task's. We are
In our asp.net 2.0 application we have the an HttpModule and HttpHandler. They are
I'm trying to find an answer for a problem my developers are having. I
I've run into quite an awkward predicament in a project at work. We need

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.