[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
:afrog:
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.
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.
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.