示例#1
0
        private void Run(
#if WITH_SERVICE_MODEL
            System.ServiceModel.Dispatcher.ExceptionHandler eh = null
#endif
            )
        {
            try
            {
                while (_grabState == GrabState.Running || _grabState == GrabState.Pause)
                {
                    if (_grabState == GrabState.Pause)
                    {
                        _pauseEvent.WaitOne();
                    }
                    else if (IntPtr.Zero.Equals(_ptr) || !Grab())
                    {
                        //capture has been released, or
                        //no more frames to grab, this is the end of the stream.
                        //We should stop.
                        _grabState = GrabState.Stopping;
                    }
                }
            }
            catch (Exception e)
            {
#if WITH_SERVICE_MODEL
                if (eh != null && eh.HandleException(e))
                {
                    return;
                }
#endif
                throw new Exception("Capture error", e);
            }
            finally
            {
                _grabState = GrabState.Stopped;
            }
        }
 internal static bool HandleTransportExceptionHelper(Exception exception)
 {
     if (exception == null)
     {
         throw Fx.AssertAndThrow("Null exception passed to HandleTransportExceptionHelper.");
     }
     System.ServiceModel.Dispatcher.ExceptionHandler transportExceptionHandler = TransportExceptionHandler;
     if (transportExceptionHandler == null)
     {
         return(false);
     }
     try
     {
         if (!transportExceptionHandler.HandleException(exception))
         {
             return(false);
         }
     }
     catch (Exception exception2)
     {
         if (Fx.IsFatal(exception2))
         {
             throw;
         }
         if (DiagnosticUtility.ShouldTraceError)
         {
             DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Error);
         }
         return(false);
     }
     if (DiagnosticUtility.ShouldTraceError)
     {
         DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Error);
     }
     return(true);
 }