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

📄 schedulerthread.cs

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

namespace NetBpm.Workflow.Scheduler.EComp.Impl
{
	public class SchedulerThread : IStartable
	{
		private static readonly ILog log = LogManager.GetLogger(typeof (SchedulerThread));
		private Thread jobThread = null;
		private bool _runing = false;

		public bool Runing
		{
			get { return _runing; }
			set { this._runing = value; }
		}

		public SchedulerThread()
		{
		}

		public void Start()
		{
			Runing=true;
			if (jobThread == null)
			{
				ThreadStart myThreadDelegate = new ThreadStart(Run);
				jobThread = new Thread(myThreadDelegate);
				jobThread.Name = "JobThread";
				jobThread.Start();
			}
		}

		public void Stop()
		{
			Runing=false;
			jobThread=null;
		}

		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);
			}
		}
	}
}

⌨️ 快捷键说明

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