Click here to Skip to main content
15,923,909 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello,

I am working on a C# application which runs in the background without any windows control.
I want to notify Windows that my application is still alive and prevents the Windows to enters into the idle state.

Is there any APIs available to call from my application which notify Windows OS that my application is still alive?

Thanks in advance.
Posted
Updated 9-Jun-11 19:07pm
v2
Comments
Dave Kreskowiak 10-Jun-11 17:46pm    
You cannot prevent Windows from entering an Idle state. Windows spends a ton of time idle. If you tried to prevent this, your app would hog the CPUs and slow the system down to a crawl.

Are you trying to prevent Windows from going to Sleep?

You never need it. For application without UI and console the idle state is not applicable. Your application will run normally until finished if written correctly.

If you have any problem with that, ask a question about it. Don't blame Windows for suspending your application — it cannot be the case.

—SA
 
Share this answer
 
Comments
[no name] 10-Jun-11 16:23pm    
I agree. Have a 5.
Sergey Alexandrovich Kryukov 11-Jun-11 20:21pm    
Thank you, Collin.
--SA
[no name] 11-Jun-11 16:21pm    
SAKryukov's answer is short and correct, my 5. There is no need to do something like this!
Sergey Alexandrovich Kryukov 11-Jun-11 20:21pm    
Thank you.
--SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Jun-11 14:51pm    
Incorrect. Please see my answer. (I did not vote.)
--SA
Your best bet would be to create your app as a Windows Service, rather than an application. The alternative is to use the Win32 API SetThreadExecutionState which would require P/Invokes and such like.

Hope this helps
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Jun-11 14:52pm    
I disagree. There is no need in that. Windows Service is completely redundant (but might be useful by different reasons). Please see my answer. (I did not vote.)
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900