Esempio n. 1
0
 public static void TryClearPriority(int priority)
 {
     try
     {
         LOG.Info("Clearing Hyperion priority");
         ClearPriority(priority);
         Thread.Sleep(50);
         ClearPriority(priority);
         LOG.Info("Hyperion priority cleared");
     }
     catch (Exception ex)
     {
         LOG.Error("Failed to clear Hyperion priority", ex);
         NotificationUtils.Error($"Failed to clear Hyperion priority. {ex.Message}");
     }
 }
Esempio n. 2
0
        private static void StartCapture()
        {
            int captureAttempt = 1;

            while (_captureEnabled)
            {
                try // This block will help retry capture before giving up
                {
                    InitScreenCapture();
                    InitProtoClient();
                    TransmitNextFrame();
                    _screenCapture.DelayNextCapture();

                    // Reset attempt count
                    captureAttempt = 1;
                }
                catch (Exception ex)
                {
                    LOG.Error($"Exception in screen capture attempt: {captureAttempt}", ex);
                    if (captureAttempt > AppConstants.REINIT_CAPTURE_AFTER_ATTEMPTS)
                    {
                        // After a few attempt, try disposing screen capture object as well
                        _screenCapture?.Dispose();
                        LOG.Info("Will re-initialize screen capture on retry");
                    }
                    if (++captureAttempt == AppConstants.MAX_CAPTURE_ATTEMPTS)
                    {
                        LOG.Error("Max screen capture attempts reached. Giving up.");
                        NotificationUtils.Error(ex.Message);
                        return;
                    }
                    else
                    {
                        LOG.Info("Waiting before next screen capture attempt");
                        Thread.Sleep(AppConstants.CAPTURE_FAILED_COOLDOWN_MILLIS);
                    }
                }
            }
        }