Ejemplo n.º 1
0
 /// <summary>
 /// If power manager for the application is null, create one and attach it to the main window to listen for power broadcasts
 /// </summary>
 private void InitializePowerManager()
 {
     if (_powerManager == null && this.MainWindow != null)
     {
         // Find main window's handle to attach power manager
         _powerManager = new PowerManager();
         if (this.MainWindowHandle != IntPtr.Zero)
         {
             _powerManager.AttachHwnd(this.MainWindowHandle, ServiceProvider.Logger);
         }
         _powerManager.SystemSuspending += OnPowerManagerSystemSuspending;
         _powerManager.SystemResumed    += OnPowerManagerSystemResumed;
     }
 }