private void Scheduler_OnError(object sender, TaskExceptionEventArgs e)
 {
     if (MgmtSession.Instance.TryGetComponent(WriteErrorKey, out EventHandler <StreamEventArgs> writeErrorEvent))
     {
         writeErrorEvent(this, new StreamEventArgs()
         {
             Resource = e.Exception
         });
     }
 }
Exemplo n.º 2
0
        private void Task_OnTaskException(object sender, TaskExceptionEventArgs e)
        {
            try
            {
                IPubSubResult result = PubSubClient.Publish(new PubSubMessage
                {
                    Event   = "task:onexception",
                    Channel = "panteon",
                    Payload = new
                    {
                        TaskName = Name
                    }
                });

                Console.WriteLine(result.Body);
            }
            catch (Exception exception)
            {
                WorkerLogger.Error($"An error occurred while informing about [{Name}] exception.", exception);
            }
        }
Exemplo n.º 3
0
 public void RaiseTaskException(TaskExceptionEventArgs e) => _taskException?.Invoke(e);
Exemplo n.º 4
0
        protected override void OnTaskException(TaskExceptionEventArgs eventArgs)
        {
            progress.SetState(4, $"Stopped (Error {eventArgs.Exception.ToString()})");

            base.OnTaskException(eventArgs);
        }
Exemplo n.º 5
0
 private void TaskErrorHandler(object sender, TaskExceptionEventArgs args)
 {
     OutputStream?.WriteError(args.TaskId, args.Exception);
 }
Exemplo n.º 6
0
 protected virtual void OnTaskException(TaskExceptionEventArgs args)
 {
     //TODO: (jmd 2015-09-30) Consider wrapping in try catch. They can force the thread to close the app.
     TaskException?.Invoke(this, args);
 }
Exemplo n.º 7
0
        protected override void OnTaskException(TaskExceptionEventArgs eventArgs)
        {
            progress.SetState(4, String.Format("Stopped (Error {0})", eventArgs.Exception.ToString()));

            base.OnTaskException(eventArgs);
        }
Exemplo n.º 8
0
        public override async Task Next(SchedulerContext <TaskInfo> context)
        {
            if (context.CancellationToken.IsCancellationRequested)
            {
                return;
            }

            if (!context.IsBusy)
            {
                // Do not fetch next task if the queue has not been started.
                if (!context.IsStarted)
                {
                    return;
                }

                if (context.Queue.Count > 0)
                {
                    // Optional delay.

                    if (context.Delay > default(TimeSpan))
                    {
                        await Task.Delay(context.Delay);
                    }

                    // Peek the current task.

                    context._current = context.Queue.Peek();

                    try
                    {
                        context.IsRunning = true;
                        context.IsBusy    = true;

                        // Execute the current task.

                        context.RaiseTaskExecuting(new TaskEventArgs(context._current));

                        await context._current.Action(context._current, context.CancellationToken);
                    }
                    catch (Exception exc)
                    {
                        // Handle any exception thrown inside a task.
                        // Invoke the Exception event handlers.

                        var eventArgs = new TaskExceptionEventArgs(context._current, exc, context.CancelOnException);

                        context.RaiseTaskException(eventArgs);

                        if (eventArgs.Cancel)
                        {
                            // Cancel the queue.

                            ClearCore(context);
                        }
                    }

                    context.RaiseTaskExecuted(new TaskEventArgs(context._current));

                    context._current = null;

                    // Dequeue the currently finished task and request the next.

                    if (context.Queue.Count > 0)
                    {
                        context.Queue.Dequeue();
                    }
                    context.IsBusy = false;
                    await Next(context);
                }
                else
                {
                    context.RaiseQueueEmpty(new QueueEventArgs());
                }
            }
            else
            {
                context.IsRunning = false;
            }
        }
        protected override void OnTaskException(TaskExceptionEventArgs eventArgs)
        {
            progress.SetState(4, $"Stopped (Error {eventArgs.Exception.ToString()})");

            base.OnTaskException(eventArgs);
        }