示例#1
0
        /**
         * Notifies every registered listener that a task execution has failed due
         * to an uncaught exception.
         *
         * @param executor
         *            The task executor.
         * @param exception
         *            The exception.
         */
        internal void notifyTaskFailed(TaskExecutor executor, ThrowableException exception)
        {
            if (executor == null)
            {
                throw new ArgumentNullException("executor", "executor is null.");
            }
            if (exception == null)
            {
                throw new ArgumentNullException("exception", "exception is null.");
            }

            lock (listeners)
            {
                int size = listeners.Count;
                if (size > 0)
                {
                    for (int i = 0; i < size; i++)
                    {
                        SchedulerListener l = (SchedulerListener)listeners[i];
                        l.TaskFailed(executor, exception);
                    }
                }
                else
                {
                    // Logs on console if no one has been notified about it.
                    Console.WriteLine(exception.ToString());
                }
            }
        }
示例#2
0
            /**
             * It implements {@link Thread#run()}, executing the wrapped task.
             */
            public void Run()
            {
                cTaskExecutor.startTime = System.DateTime.Now.Ticks;
                ThrowableException error = null;

                try
                {
                    // Notify.
                    cTaskExecutor.scheduler.notifyTaskLaunching(cTaskExecutor.myself);
                    // Task execution.
                    cTaskExecutor.task.Execute(cTaskExecutor.context);
                    // Succeeded.
                    cTaskExecutor.scheduler.notifyTaskSucceeded(cTaskExecutor.myself);
                }
                catch (Exception exception)
                {
                    // Failed.
                    error = new ThrowableException(exception);
                    cTaskExecutor.scheduler.notifyTaskFailed(cTaskExecutor.myself, error);
                }
                finally
                {
                    // Notify.
                    cTaskExecutor.NotifyExecutionTerminated(error);
                    cTaskExecutor.scheduler.notifyExecutorCompleted(cTaskExecutor.myself);
                }
            }
示例#3
0
 /**
  * Notify registered listeners the execution has been terminated.
  *
  * @param exception
  *            If the execution has been terminated due to an error, this is
  *            the encountered exception; otherwise the parameter is null.
  */
 private void NotifyExecutionTerminated(ThrowableException exception)
 {
     lock (listeners)
     {
         foreach (var l in listeners)
         {
             l.ExecutionTerminated(this, exception);
         }
     }
 }
示例#4
0
 /**
  * It implements {@link Thread#run()}, executing the wrapped task.
  */
 public void Run()
 {
     cTaskExecutor.startTime = System.DateTime.Now.Ticks;
     ThrowableException error = null;
     try
     {
         // Notify.
         cTaskExecutor.scheduler.notifyTaskLaunching(cTaskExecutor.myself);
         // Task execution.
         cTaskExecutor.task.Execute(cTaskExecutor.context);
         // Succeeded.
         cTaskExecutor.scheduler.notifyTaskSucceeded(cTaskExecutor.myself);
     }
     catch (Exception exception)
     {
         // Failed.
         error = new ThrowableException(exception);
         cTaskExecutor.scheduler.notifyTaskFailed(cTaskExecutor.myself, error);
     }
     finally
     {
         // Notify.
         cTaskExecutor.NotifyExecutionTerminated(error);
         cTaskExecutor.scheduler.notifyExecutorCompleted(cTaskExecutor.myself);
     }
 }
示例#5
0
 /**
  * Notify registered listeners the execution has been terminated.
  * 
  * @param exception
  *            If the execution has been terminated due to an error, this is
  *            the encountered exception; otherwise the parameter is null.
  */
 private void NotifyExecutionTerminated(ThrowableException exception)
 {
     lock (listeners)
     {
         foreach (var l in listeners)
         {
             l.ExecutionTerminated(this, exception);
         }
     }
 }
示例#6
0
 /**
  * Notifies every registered listener that a task execution has failed due
  * to an uncaught exception.
  * 
  * @param executor
  *            The task executor.
  * @param exception
  *            The exception.
  */
 internal void notifyTaskFailed(TaskExecutor executor, ThrowableException exception)
 {
     if (executor == null)
         throw new ArgumentNullException("executor", "executor is null.");
     if (exception == null)
         throw new ArgumentNullException("exception", "exception is null.");
     
     lock (listeners)
     {
         int size = listeners.Count;
         if (size > 0)
         {
             for (int i = 0; i < size; i++)
             {
                 SchedulerListener l = (SchedulerListener)listeners[i];
                 l.TaskFailed(executor, exception);
             }
         }
         else
         {
             // Logs on console if no one has been notified about it.
             Console.WriteLine(exception.ToString());
         }
     }
 }