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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:35:43+00:00 2026-05-18T08:35:43+00:00

There is a very common task I face again. I have already solved this

  • 0

There is a very common task I face again. I have already solved this a couple of times, but now I am looking for a more “elegant” way – can you deliver some input?

Situation:
I have a Method which I would like to run “semi async”. In other words: Start it and wait a given time x. If the method is not finished by then (“timed out”), I want to continue my code with some cleanup procedures.

Solutions so far:

  1. Use an AutoResetEvent (or
    ManualResetEvent) combined with an
    annonymus method using
    .WaitOne(x).
  2. Use a Thread/BackgroundWorker
    combined with a Timer. If the timer
    hits its handler before the thread stops it, the therad is timed out.

Both appraochs work fine but I imagine there is a better way with 4.0.

Suggestions?

  • 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-05-18T08:35:43+00:00Added an answer on May 18, 2026 at 8:35 am

    Does Task.Wait(Timeout) from the Task Parallel Library do what you want? (You may wish to combine this with cancellation tokens to cancel the task after the timeout occurs.)

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

Sidebar

Related Questions

There's something very unsatisfactory about this code: /* Given a command string in which
There is a very similar question already. One of the solutions uses code like
In my javascript experience, I found that is a very common task searching the
There is very strange assembly reference problem and loading problem I experience with my
For iPhone game development, seems there are very like functions using CALayer and UIView,
I'd like to learn assembler. However, there are very few resources for doing assembler
Can an ArrayList of Node contain a non-Node type? Is there a very dirty
There exists a very good talk about C# vs. Java where H.Mössenböck compares the
Are there any c++ networking libs that are very useful and robust? and libs
Very simple question, is there any cloud server enviroments avaliable these days for us

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.