Results 1 to 4 of 4

Thread: [2005] Detect when the main thread is sleeping?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Question [2005] Detect when the main thread is sleeping?

    Hi guys,

    I was just wondering whether it was possible to detect whether the main thread was sleeping? The reason i ask is because i have a application where the user can use keyboard short cuts to minimise the screen and close the whole application, but if the main thread is sleeping it (obviously) doesn't respond to the key pressed event until the thread is back 'awake'. Is there any way to get around this so that if the application is closed while the thread is sleeping it will close the application immediately instead of after the duration of sleep?

    Thanks in advance for any help
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

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

    Re: [2005] Detect when the main thread is sleeping?

    Well to begin with, why do you put the main thread asleep in the first place? Thats not something youd want to do.
    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)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: [2005] Detect when the main thread is sleeping?

    I do it because i have some photos that fade in and out of each other, but to make sure people can see the pics properly....i use thread.sleep(2500) at the end of each transformation and then it fades in the next image.
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

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

    Re: [2005] Detect when the main thread is sleeping?

    Well in that case I advice you to do one of the following:

    1. Put the code in a worker thread (Or simpler, use the backgroundworker)
    2. Use a timer when cycling between the pictures.
    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