protected void Run()
        {
            do
            {
                lock (Pipe)
                {
                    if (Pipe.Connected)
                    {
                        continue;
                    }
                    Connected = false;

                    if (!Pipe.Connect())
                    {
                        continue;
                    }
                    if (!SyncUser() || !SyncAll())
                    {
                        Pipe.Dispose();
                        continue;
                    }
                    Connected = true;
                }
            }while (!AsyncManager.StopEvent.WaitOne(500));
        }
 /// <summary>
 /// Disposes the CustomLogger, releases resources and supresses the finalizer
 /// </summary>
 protected override void OnDispose()
 {
     base.OnDispose();
     if (_client != null)
     {
         _client.Dispose();
         _client = null;
     }
 }
        /// <summary>
        ///     Stops the service
        /// </summary>
        public void Stop()
        {
            try
            {
                // Wait for Pipe communication to stop
                _pipeClient.WaitForDrain();

                // Close Pipe
                _pipeClient.Dispose();

                _memoryCache.Set(SERVICE_MEMORY, false);
            }

            catch (ObjectDisposedException ode)
            {
                _loggerService.LogMessage(SERVICE_NAME,
                                          ode.Message, LogLevel.Error);

                _memoryCache.Set(SERVICE_MEMORY, false);

                throw new ErrorProcessingServiceException(ode.Message);
            }

            catch (NotSupportedException nse)
            {
                _loggerService.LogMessage(SERVICE_NAME,
                                          nse.Message, LogLevel.Error);

                _memoryCache.Set(SERVICE_MEMORY, false);

                throw new ErrorProcessingServiceException(nse.Message);
            }

            catch (IOException ioe)
            {
                _loggerService.LogMessage(SERVICE_NAME,
                                          ioe.Message, LogLevel.Error);

                _memoryCache.Set(SERVICE_MEMORY, false);

                throw new ErrorProcessingServiceException(ioe.Message);
            }

            catch (InvalidOperationException ioe)
            {
                _loggerService.LogMessage(SERVICE_NAME,
                                          ioe.Message, LogLevel.Error);

                _memoryCache.Set(SERVICE_MEMORY, false);

                throw new ErrorProcessingServiceException(ioe.Message);
            }
        }
Example #4
0
 public void TearDown()
 {
     if (server != null)
     {
         server.Dispose();
         server = null;
     }
     if (client != null)
     {
         client.Dispose();
         client = null;
     }
 }
Example #5
0
 protected virtual void Dispose(bool disposing)
 {
     if (_disposed)
     {
         return;
     }
     if (disposing && Initialized)
     {
         try {
             CameraWrapper.Dispose();
         }
         catch (Exception e)
         {
             Console.WriteLine("EDSDK shutdown error: " + e);
         }
         PipeWriter.Dispose();
         PipeClient.Dispose();
     }
     _disposed = true;
 }