Esempio n. 1
0
        public void RunSingleTask(ScheduleItem s)
        {
            numberOfProcessesInQueue++;
            numberOfProcesses++;
            ScheduleHistoryItem obj = new ScheduleHistoryItem();

            obj.TypeFullName              = s.TypeFullName;
            obj.Id                        = s.Id;
            obj.TimeLapse                 = s.TimeLapse;
            obj.TimeLapseMeasurement      = s.TimeLapseMeasurement;
            obj.RetryTimeLapse            = s.RetryTimeLapse;
            obj.RetryTimeLapseMeasurement = s.RetryTimeLapseMeasurement;
            obj.ObjectDependencies        = s.ObjectDependencies;
            obj.CatchUpEnabled            = s.CatchUpEnabled;
            obj.Enabled                   = s.Enabled;
            obj.NextStart                 = s.NextStart;
            obj.ScheduleSource            = s.ScheduleSource;
            obj.SetSettings(s.GetSettings());
            obj.ThreadID     = s.ThreadID;
            obj.ProcessGroup = s.ProcessGroup;

            try
            {
                Run(obj);
                Thread.Sleep(1000);
            }
            catch (Exception exc)
            {
                //Exceptions.ProcessSchedulerException(exc);
                throw exc;
            }
        }
Esempio n. 2
0
        // ''''''''''''''''''''''''''''''''''''''''''''''''''
        // Add a queue request to Threadpool with a
        // callback to RunPooledThread which calls Run()
        // ''''''''''''''''''''''''''''''''''''''''''''''''''
        public void AddQueueUserWorkItem(ScheduleItem s)
        {
            numberOfProcessesInQueue++;
            numberOfProcesses++;

            // Create the history item
            ScheduleHistoryItem objHist = new ScheduleHistoryItem();

            objHist.TypeFullName              = s.TypeFullName;
            objHist.Id                        = s.Id;
            objHist.TimeLapse                 = s.TimeLapse;
            objHist.TimeLapseMeasurement      = s.TimeLapseMeasurement;
            objHist.RetryTimeLapse            = s.RetryTimeLapse;
            objHist.RetryTimeLapseMeasurement = s.RetryTimeLapseMeasurement;
            objHist.ObjectDependencies        = s.ObjectDependencies;
            objHist.CatchUpEnabled            = s.CatchUpEnabled;
            objHist.Enabled                   = s.Enabled;
            objHist.NextStart                 = s.NextStart;
            objHist.ScheduleSource            = s.ScheduleSource;
            objHist.SetSettings(s.GetSettings());
            objHist.ThreadID     = s.ThreadID;
            objHist.ProcessGroup = s.ProcessGroup;

            try
            {
                // Use a standard thread to run the scheduled item iinstead of a pool thread
                // Store the history item
                this.historyItem = objHist;
                System.Threading.Thread threadItem = new System.Threading.Thread(new ThreadStart(this.RunStandardThread));
                threadItem.IsBackground = true;
                threadItem.Start();

                /*
                 * // Create a callback to subroutine RunPooledThread, this will be called
                 * // by our thread pool thread
                 * System.Threading.WaitCallback callback = new System.Threading.WaitCallback(RunPooledThread);
                 * //  And put in a request to ThreadPool to run the process.
                 * System.Threading.ThreadPool.QueueUserWorkItem(callback, (Object)objHist);
                 */

                // Suspend this threads quantum for a second
                Thread.Sleep(1000);
            }
            catch (Exception exc)
            {
                //Exceptions.ProcessSchedulerException(exc);
                throw exc;
            }
        }