Thomas Mapother

Thomas Mapother

  • NA
  • 158
  • 87.6k

Environment.HasShutdownStarted property in C#

Aug 2 2011 12:38 AM

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)