コード例 #1
0
		private void RunSmartWorkersInPriorityOrder(SmartWorker worker, VisualCounter[] counters)
		{
			while (true)
			{
				var item = counters
					.Select((counter, i) => new Tuple<int, VisualCounter>(i, counter))
					.Where(x => x.Item2.Counter != x.Item2.MaxWorkers)
					.OrderBy(x => x.Item2.Counter)
					.FirstOrDefault();

				if (item != null)
				{
					worker.Execute(counters[item.Item1]);
				}
			}
		}
コード例 #2
0
		private void RunSmartWorkersInSequence(SmartWorker worker, VisualCounter[] counters)
		{
			var index = RandomNumber.Next();

			while (true)
			{
				worker.Execute(counters[index]);

				if (++index > 24)
					index = 0;
			}
		}
コード例 #3
0
		private void RunSmartWorkersInRandom(SmartWorker worker, VisualCounter[] counters)
		{
			while (true)
			{
				var index = RandomNumber.Next();
				worker.Execute(counters[index]);
			}
		}
コード例 #4
0
		private void RunSmartWorker(object state)
		{
			var castState = state as State;
			var counters = castState.Counters;
			var worker = new SmartWorker();
			
			Algorithm algorithm = null;
			var algorithmList = castState.AlgorithmList;
			algorithmList.Parent.Invoke(new MethodInvoker(delegate()
			{
				algorithm = algorithmList.SelectedItem as Algorithm;
			}));

			algorithm.Function(worker, counters);
		}