Beispiel #1
0
        public static void Main(String[] args)
        {
            try
            {
                bool loop = true;
                if (args.Length != 1)
                {
                    Console.Out.WriteLine("SchedulerMain loop(true|false)");
                }
                ServiceLocator sl = ServiceLocator.Instance;

                if (args.Length > 0 && args[0].EndsWith("false"))
                {
                    loop = false;
                }
                ISchedulerSessionLocal schedulerSessionRemote = SchedulerSessionRemote;

                while (loop)
                {
                    long millisToWait = DEFAULT_INTERVAL;

                    try
                    {
                        if (schedulerSessionRemote != null)
                        {
                            Console.Out.WriteLine(DateTime.Now + " : scheduling task...");
                            millisToWait = schedulerSessionRemote.ExecuteJobs();
                        }
                        else
                        {
                            schedulerSessionRemote = SchedulerSessionRemote;
                        }
                    }
                    catch (Exception t)
                    {
                        Console.WriteLine("Error: " + t.Message);
                    }

                    Console.Out.WriteLine("going to sleep for " + millisToWait + " milliseconds...");
                    Thread.Sleep(new TimeSpan(10000 * millisToWait));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.Message);
            }
        }
Beispiel #2
0
        public void Run()
        {
            ISchedulerSessionLocal scheduler = null;

            try
            {
                scheduler = (ISchedulerSessionLocal)ServiceLocator.Instance.GetService(typeof(ISchedulerSessionLocal));
                while (Runing)
                {
                    //do somting
                    log.Debug("SchedulerThread ExecuteJobs");
                    scheduler.ExecuteJobs();
                    //sleep 5 seconds
                    Thread.Sleep(5000);
                }
            }
            finally
            {
                ServiceLocator.Instance.Release(scheduler);
            }
        }