Esempio n. 1
0
        /// <summary>
        /// This method registers a process to be polled as part of the process loop.
        /// </summary>
        /// <typeparam name="C">The process context type.</typeparam>
        /// <param name="name">The process name.</param>
        /// <param name="ordinal">The process priority ordinal</param>
        /// <param name="process">The task manager process.</param>
        /// <param name="context">The context of type C. The default(C) if not set.</param>
        public void ProcessRegister <C>(string name, int ordinal, ITaskManagerProcess process, C context = default(C))
        {
            var holder = new TaskManagerProcessContext <C>(name)
            {
                Ordinal = ordinal, Process = process, Context = context
            };

            process.TaskSubmit       = ExecuteOrEnqueue;
            process.TaskAvailability = mAvailability;
            mProcesses.AddOrUpdate(name, holder, (n, o) => holder);
        }
Esempio n. 2
0
 /// <summary>
 /// This method executes a particular process synchronously, and catches any exceptions that might be thrown.
 /// </summary>
 /// <param name="context">The process to execute.</param>
 private void ProcessExecute(TaskManagerProcessContext context)
 {
     try
     {
         if (context.Process.CanProcess())
         {
             context.Process.Process();
         }
     }
     catch (Exception ex)
     {
         Collector?.LogException($"ProcessExecute failed: {context.Name}", ex);
     }
 }