⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 schedulermain.cs

📁 基于DotNet的开源工作流引擎
💻 CS
字号:
using System;
using System.Threading;
using NetBpm.Util.Client;
using NetBpm.Workflow.Scheduler.EComp;

namespace NetBpm.Workflow.Scheduler.Impl
{
	public class SchedulerMain
	{
		private static ISchedulerSessionLocal SchedulerSessionRemote
		{
			get
			{
				ServiceLocator serviceLocator = ServiceLocator.Instance;
				ISchedulerSessionLocal schedulerSessionRemote = (ISchedulerSessionLocal) serviceLocator.GetService(typeof (ISchedulerSessionLocal));
				return schedulerSessionRemote;
			}

		}

		private static long DEFAULT_INTERVAL = 5000;

		[STAThread]
		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);
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -