Results 1 to 8 of 8

Thread: [2005] 5 sec wait till event

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2007
    Posts
    36

    [2005] 5 sec wait till event

    Hi

    I wondered if there is a code that does this

    private function getexit()
    'code thats let the app wait till the 5 sec are over
    close()

    end function

    So the app have to close after 5 sec
    can someone help me with this?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2005] 5 sec wait till event

    to suspend execution for 5 seconds

    vb Code:
    1. threading.thread.sleep(5000)

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [2005] 5 sec wait till event

    Quote Originally Posted by .paul.
    to suspend execution for 5 seconds

    vb Code:
    1. threading.thread.sleep(5000)
    Works great. I was kind of wondering what would be the .NET replacement for the Sleep API
    vb.net Code:
    1. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    2.         Threading.Thread.Sleep(5000)
    3. End Sub

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2005] 5 sec wait till event

    You could add a timer, set the interfal to 5000, then exit the program on the tick event. That would keep from shutting down the UI.
    My usual boring signature: Nothing

  5. #5
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] 5 sec wait till event

    Why would anyone want to sleep the main thread for 5 full seconds?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  6. #6
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: [2005] 5 sec wait till event

    I was thinking the exact same thing. I don't think I've ever heard of a good reason for sleeping the UI thread before. Usually the programmer is designing something the wrong way.

    Actually, after rereading the original poster's question, it seems apparent that he doesn't actually want to sleep the original thread, just to exit 5 seconds after the event is called. Because of this, I don't think sleeping or halting any threads at all, be it of the UI or worker.

    The way I would do it would be to use Shaggy's solution. Sure, the Timer is only run once, but I believe it encapsulates such behavior very well.

  7. #7

    Thread Starter
    Member
    Join Date
    Dec 2007
    Posts
    36

    Re: [2005] 5 sec wait till event

    the thing is that the app i made scans files in a client folder and if the files are modyfided the app delete those files and download fresh ones from the web but the scan and replace goes so fast that users cant see the log cuz the app ends after scan event cuz the game starts then. now users got the time to read

  8. #8
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] 5 sec wait till event

    Why can you not just let the user click a button to have the game launched at the end instead of launching it automatically? Then the user would have as much time to read as he'd need. OR you could activate a timer with a tick of 10 seconds, instead of launching the game. When the timer has raised the tick event, launch the game.
    If I where to have an application that became unresponsive for longer period of times, Id get really annoyed. If someone then told me that it is actually programmed to do so, I'd uninstall it right away.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width