4
Answers

Environment.HasShutdownStarted property in C#

Thomas Mapother

Thomas Mapother

13y
3.7k
1

Hi,

I want to create an application which works when system is shutting down. So, my question is that is it right way to implement Environment.HasShutdownStarted property for my propose..?


 SystemEvents.SessionEnding +=
             new SessionEndingEventHandler(SystemEvents_SessionEnding);
 
  void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
  {
      if (Environment.HasShutdownStarted)
      {
          //…………………………
      }
      else
      {
          //………………
      }
   }


Answers (4)