|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
namespace ANN.Perceptron.Common
{
#region Public Delegates
// delegates used to call MainForm functions from worker thread
public delegate void DelegateAddObject(int i, Object s);
public delegate void DelegateAddObjects(int i, Object[] s);
#endregion
public partial class BaseControl : UserControl
{
public DelegateAddObject DelegateAddObject;
public DelegateAddObjects DelegateAddObjects;
public ParallelOptions ParallelOption { get; protected set; }
protected int _maxDegreeOfParallelism = Environment.ProcessorCount;
public int MaxDegreeOfParallelism
{
get
{
return _maxDegreeOfParallelism;
}
set
{
if (value == _maxDegreeOfParallelism)
return;
if ((value == 0) || (value > Environment.ProcessorCount))
_maxDegreeOfParallelism = -1;
else
_maxDegreeOfParallelism = value;
ParallelOption.MaxDegreeOfParallelism = _maxDegreeOfParallelism;
}
}
protected System.Diagnostics.Stopwatch stopwatch;
public BaseControl()
{
InitializeComponent();
DelegateAddObject = new DelegateAddObject(this.AddObject);
DelegateAddObjects = new DelegateAddObjects(this.AddObjects);
ParallelOption = new ParallelOptions();
ParallelOption.TaskScheduler = null;
_maxDegreeOfParallelism = Environment.ProcessorCount;
ParallelOption.MaxDegreeOfParallelism = _maxDegreeOfParallelism;
stopwatch = new Stopwatch();
}
protected virtual void AddObject(int iCondition, object value)
{
return;
}
protected virtual void AddObjects(int iCondition, object[] values)
{
return;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.