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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:29:04+00:00 2026-06-04T15:29:04+00:00

After my application froze I tracked down the cause to a thread waiting on

  • 0

After my application froze I tracked down the cause to a thread waiting on a task created by Task.Delay() (or TaskEx.Delay() in .NET 4.0) for which it provided a computed TimeSpan that, due to a bug, was on occasion computed to a TimeSpan with a TotalMilliseconds of less than or equal to -1 and greater than -2 (i.e. anywhere between -10000 to -19999 ticks, inclusive).

It appears that when you pass a negative TimeSpan that is -2 milliseconds or lower, the method correctly throws an ArgumentOutOfRangeException, but when you provide a negative TimeSpan from the range described above, it returns a Task that never completes (by setting the underlying System.Threading.Timer to a dueTime of -1 which denotes infinity). That means that any continuations set on that task will never execute, and any poor thread that happens to .Wait() on that Task will forever be blocked.

What possible use can a Task that never completes have? Would anyone expect such a return value? Shouldn’t any negative value passed to .Delay(), including values in that special range, throw an ArgumentOutOfRangeException?

  • 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-04T15:29:05+00:00Added an answer on June 4, 2026 at 3:29 pm

    Timeout.Infinite or -1 is useful when you want to wait indefinitely for a long-running task that will take an indeterminate amount of time to complete, but will eventually complete.

    The Win32 API also uses a constant INFINITE = -1 for infinite timeouts.

    You wouldn’t normally want to use it in a UI thread, as it could freeze the UI (which seems to be your problem). But there are valid use cases in a worker thread – e.g. a server that is blocking waiting for a connection from a client.

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

Sidebar

Related Questions

I want to save some integers after application shut down and restore them after
I am developing a C# application (.Net 3.5, Win Forms) which is run on
I have a modal view, which I show after application launch. The problem now
In my application after login I am going into home page. But from home
I have been developing a sample application after reading Rails 3 Tutorial book. In
My Question: Performance tests are generally done after an application is integrated with various
I've had some problems with a Django application after I deployed it. I use
When the users attempt login to my application after supplying credentials & pressing the
Is there any way to change the icon of an application after it is
is it possible to control the iAd in my application after it's launched ?

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.