示例#1
0
 private void StopImpl()
 {
     if(receiver != null) {
         if(receiver.IsHandleCreated) {
             receiver.Close();
             receiver.Dispose();
             GC.SuppressFinalize(receiver);
             receiver = null;
         }
     }
 }
示例#2
0
        public bool Start()
        {
            // check if we are running on Vista+
            if(IsUnderVista() == false) {
                return false;
            }

            Debug.ReportWarning("Started listening to power notifications");

            // show the window
            receiver = new PowerNotificationsReceiver();
            receiver.Manager = this;

            if(_baseControl != null) {
                // WinForms start
                _baseControl.Invoke(new MethodInvoker(WinFormsStart));
            }
            else {
                receiver.Show();
                receiver.Start();
            }

            return true;
        }