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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:08:54+00:00 2026-05-26T21:08:54+00:00

I need a better design for sleeping Task than Thread.Sleep, I’m using the Task

  • 0

I need a better design for sleeping Task than Thread.Sleep, I’m using the Task class.

In my wpf app i run a Task, this task runs another couple of tasks, each of this tasks first login to and Internet website, after they login they need to wait couple of seconds and inform the user when they will proceed further and this is my problem, because with Thread.Sleep i can’t report the progress.

There are more functions than login, it’s about 5-6, all of them request an Internet resource, and between them there need to be a sleep time with remaining time report send do gui, this 5-6 function are all in one Task, but there could be many tasks.

What i need is to make the task wait, but also allow it to send updates on the remaining time to proceed to the GUI.

Do you have any ideas for this problem, how to make it better, maybe you have some design patterns already for such problem?

I have heard also that using Thread.Sleep is a poor design practice.

EDIT: No one knows ?
Whats with some kind of self contained timer with thread wait like waithandle, autoresetevent, anybody?

  • 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-26T21:08:54+00:00Added an answer on May 26, 2026 at 9:08 pm

    Forget using Thread.Sleep. Instead, run your task in a background thread and use a WaitHandle with an AutoResetEvent. (Links: WaitHandle/WaitOne / AutoReset)

    Your background thread can send updates to UI with async delegates, but the calling thread will wait it until either thing happens:

    1) Your thread reports it has completed its task by using yourwaithandle.Set();

    or

    2) the waiting thread timeouts (timeout value is set as parameter to WaitOne() -method).

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

Sidebar

Related Questions

I need a serialization library for .net with better features than the default xml
I am a newbie in Obj-C. I need to learn this better so please
I'm looking for ideas on the best way to refactor this scenario (better design,
I need to design some kind of book-shelf-looking view for an Android app I'm
This is a design question rather than a Java-specific question, but I'm designing it
Having this design : interface Foo<T> { void doSomething(T t); } class FooImpl implements
I'm working on a project, and we're gonna need some better tools as it's
i need to identify who raise an exception to handle better str error, is
Which approach is better to use if I need a member (sp or func)
Can you do a better code? I need to check/uncheck all childs according to

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.