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

  • Home
  • SEARCH
  • 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 8866865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:53:20+00:00 2026-06-14T16:53:20+00:00

Question is taken from here: SO – Timeout in c# tests I created a

  • 0

Question is taken from here: SO – Timeout in c# tests

I created a simple unit test like this:

[Timeout(1000)][TestMethod]
public void TestMethod1()
{
    try
    {
        System.Threading.Thread.Sleep(2000);
    }
    finally
    {
        Console.WriteLine("Executed");
    }
}

When I run the test, the finally block is not executed. But when I debug it, it does. Why is this happening?

  • 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-14T16:53:21+00:00Added an answer on June 14, 2026 at 4:53 pm

    You specify the test timeout at 1000 ms, while your method sleeps for 2000 ms. This results in your test method being prematurely force-closed by the test framework, so it doesn’t leave the Sleep call and doesn’t have time to reach finally block. Debugging probably disables the timeout attribute.

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

Sidebar

Related Questions

Snippet taken from this question from django.db.models import F ... MyModel.objects.filter(id=...).update(hit_count=F(hit_count)+1) It was suggested
This snippet (taken from this question ) compiles fine with g++ (as seen), so
Here are some snippets in different languages. Function double in question is taken from
This code is taken from a previous question, but my question directly relates to
Taken from an answer to this question , as an example, this is a
I'm writing this question because one little invisible problem has taken from me hours
First, I've taken the time to review this question which seems to be the
I dont know if this is a duplicate but here's my question.. I was
Taken from here: http://www.cplusplus.com/doc/tutorial/inheritance/ What is inherited from the base class? In principle, a
Another simple question. I found this really cool snippet of code: $date_str = Jan

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.