示例#1
0
 private void StartLiveViewThread()
 {
     try
     {
         _totalframes = 0;
         _framestart  = DateTime.Now;
         bool retry    = false;
         int  retryNum = 0;
         Log.Debug("LiveView: Liveview started");
         do
         {
             try
             {
                 LiveViewManager.StartLiveView(SelectedPortableDevice);
             }
             catch (DeviceException deviceException)
             {
                 Dispatcher.Invoke(new Action(delegate { grid_wait.Visibility = Visibility.Visible; }));
                 if (deviceException.ErrorCode == ErrorCodes.ERROR_BUSY ||
                     deviceException.ErrorCode == ErrorCodes.MTP_Device_Busy)
                 {
                     Thread.Sleep(200);
                     if (!IsVisible)
                     {
                         break;
                     }
                     Log.Debug("Retry live view :" + deviceException.ErrorCode.ToString("X"));
                     retry = true;
                     retryNum++;
                 }
                 else
                 {
                     throw;
                 }
             }
         } while (retry && retryNum < 35);
         if (IsVisible)
         {
             _timer.Start();
             oper_in_progress = false;
             _retries         = 0;
             Log.Debug("LiveView: Liveview start done");
         }
     }
     catch (Exception exception)
     {
         Log.Error("Unable to start liveview !", exception);
         StaticHelper.Instance.SystemMessage = "Unable to start liveview ! " + exception.Message;
         //MessageBox.Show("Unable to start liveview !");
         //ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.LiveViewWnd_Hide);
     }
     Dispatcher.BeginInvoke(new Action(delegate { grid_wait.Visibility = Visibility.Hidden; }));
     Dispatcher.BeginInvoke(new Action(delegate { image1.Visibility = Visibility.Visible; }));
 }
示例#2
0
 private void StartLiveViewThread()
 {
     try
     {
         bool retry    = false;
         int  retryNum = 0;
         Log.Debug("LiveView: Liveview started");
         do
         {
             try
             {
                 LiveViewManager.StartLiveView(CameraDevice);
             }
             catch (DeviceException deviceException)
             {
                 if (deviceException.ErrorCode == ErrorCodes.ERROR_BUSY ||
                     deviceException.ErrorCode == ErrorCodes.MTP_Device_Busy)
                 {
                     Thread.Sleep(200);
                     if (!IsVisible)
                     {
                         break;
                     }
                     Log.Debug("Retry live view :" + deviceException.ErrorCode.ToString("X"));
                     retry = true;
                     retryNum++;
                 }
                 else
                 {
                     throw;
                 }
             }
         } while (retry && retryNum < 35);
         if (IsVisible)
         {
             _oper_in_progress = false;
             _liveviewtimer.Start();
             Log.Debug("LiveView: Liveview start done");
         }
     }
     catch (Exception exception)
     {
         Log.Error("Unable to start liveview !", exception);
         StaticHelper.Instance.SystemMessage = "Unable to start liveview ! " + exception.Message;
         //MessageBox.Show("Unable to start liveview !");
         //ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.LiveViewWnd_Hide);
     }
 }