Click here to Skip to main content
15,884,739 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Friends,

I am new in C#, so anyone tell me the following conditions:

1)I developed an application which is currently running.
2)Now I am going for shut down the system.
3)In this condition application ask me "Do you want to close the application?"
4)My requirement is if I am going for shut down the system the running application is not ask me to close or not. The system directly shut down without asking.
5)Also tell me that how to detect that the system is shut down or not.

I want to do this with an application which is generated in C# 3.0 and my visual studio is 2005

Please help me to resolve this.

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 19-Jun-13 9:20am    
Just a note: if a system is shut down, it's too late, isn't it? :-)
But you can handle the situation when a system started shutting down and even delay it.
—SA

It might not cover all possible situations, but it will cover your requirements: Make Your Application Shutdown Aware[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 19-Jun-13 9:19am    
5ed.
—SA
Zoltán Zörgő 19-Jun-13 9:27am    
Thank you.
You can add a handler to the SystemEvents.SessionEnding[^] event, but you should just get an appliction exit command through the normal channels - you can just ask in that.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 19-Jun-13 9:19am    
Correct, a 5.
—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