code: public int invoke()
      {
          int workCount = 0;
          if (isRunning)
          {
              try
              {
                  workCount = agent.doWork();
              }
              catch (final InterruptedException | ClosedByInterruptException ignore)
              {
                  close();
                  Thread.currentThread().interrupt();
              }
              catch (final AgentTerminationException ex)
              {
                  handleError(ex);
                  close();
              }
              catch (final Throwable throwable)
              {
                  handleError(throwable);
              }
          }
  
          return workCount;
      }
docs: Invoke the {@link Agent#doWork()} method and return the work count.
  <p>
  If an error occurs then the {@link AtomicCounter#increment()} will be called on the errorCounter if not null
  and the {@link Throwable} will be passed to the {@link ErrorHandler#onError(Throwable)} method. If the error
  is an {@link AgentTerminationException} then {@link #close()} will be called after the error handler.
  <p>
  If not successfully started or after closed then this method will return without invoking the {@link Agent}.
  
  @return the work count for the {@link Agent#doWork()} method.