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 8494377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:16:58+00:00 2026-06-10T23:16:58+00:00

In ASP.NET 4.0 web pages, I would like to detect and prevent code that

  • 0

In ASP.NET 4.0 web pages, I would like to detect and prevent code that runs too long. So I’m looking for a construct like this:

try for 1000 ms
{
    RunPotentiallyTooLongCode();
}
catch
{
    RecordError( "code ran out of control" );
    // let user know
    ...
}

Although we’re currently using 4.0, I would also be interested in solutions for 4.5, perhaps the async features added would help.

  • 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. Editorial Team
    Editorial Team
    2026-06-10T23:17:00+00:00Added an answer on June 10, 2026 at 11:17 pm

    You’d spawn a new thread for the long-running task, then block and wait for that thread to complete or until a timeout has been reached. If the timeout was reached then the task has presumably blocked (either an infinite loop, a deadlock, or a blocking IO wait) and you can terminate the thread.

    Thread thread = new Thread( RunPotentiallyTooLongCode );
    thread.Start();
    Boolean success = thread.Join( 1000 );
    if( !success ) thread.Abort();
    

    There’s no need to use the 4.0 async stuff here. In fact this code will run fine on .NET 1.0 too.

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

Sidebar

Related Questions

I want to prevent my asp.net / c# 2008 web pages from being cached
I am looking to split my css into sections with my asp.net web pages
I am using ASP.NET MVC to develop a web application and would like to
I'm trying to build an ASP.NET page that can crawl web pages and display
I have an asp.net web page (C# 2008) where the user would enter an
I'm using ASP.NET Web Pages to create a form in which I can select
I have an ASP.Net web site (ASPX and ASMX pages) with a single web.config
I'm adding some ASP.NET MVC pages to an existing ASP.NET Web Forms project. I've
I have a ASP.NET web application which has more than 100 pages. Each page
I've watched and viewed lots of pages on securing asp.net web api's - including:

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.