Ejemplo n.º 1
0
 public void Stop()
 {
     if (!IsRunning)
     {
         throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "{0} is already stopped.", GetType().Name));
     }
     StopRequested = true;
     ProcessingThread.Join();
     StopRequested = false;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Called by OnStop of the Service, to halt current processing.
 /// </summary>
 public void StopProcessing()
 {
     try
     {
         ThreadStopping = true;
         if (ProcessingThread != null)
         {
             ProcessingThread.Join(StopProcessingTimeOut);                       // Give it up to 5 minutes to finish.
         }
         LogEvent("Processing thread stopped.");
         Trace.WriteLine("Stopped thread: " + ProcessingThread.Name);
     }
     catch (Exception ex)
     {
         try
         {
             string err = string.Format("Error in StopProcessing(). {0}{1}", Environment.NewLine, ex.ToFullString());
             LogErrorEvent(err);
             Trace.WriteLine(err);
         }
         catch { }
     }
 }