Zak Forsman
Major Contributor
let's see it!
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
0309 3390 0000 5752 5648
A Tracking number for USPS... and of course it says "No information" !!!!
I want my package!
------------------------
On a side note: HOLY sh*t kholi, you have 4,400+ unread emails! Jeez! I am the opposite, I always keep my email at all checked. Wow.
using System.Threading;
public class MultiCore
{
private ArrayList _MultiCoreData = new ArrayList();
private Threading.ParameterizedThreadStart _MultiCoreProcess;
private ArrayList _MultiCoreList = new ArrayList();
#region "Public Properties"
public ArrayList MultiCoreData {
get { return _MultiCoreData; }
set { _MultiCoreData = value; }
}
public Threading.ParameterizedThreadStart MultiCoreProcess {
get { return _MultiCoreProcess; }
set { _MultiCoreProcess = value; }
}
#endregion
#region "MultiCore Class Constructor"
public MultiCore(ArrayList wMultiCoreData, Threading.ParameterizedThreadStart wMultiCoreProcess)
{
this.MultiCoreData = wMultiCoreData;
this.MultiCoreProcess = wMultiCoreProcess;
}
#endregion
#region "MultiCore Processing"
/// <summary>
/// Execute MultiCore is the Main Class Method,
/// the Execute starts the process initilization
/// by first Flushing all the list of old cores
/// if they exist, the number of processor cores
/// is determined. Based on the size of the of the
/// data and number of cores, the data is partitioned
/// into smaller data chunks. A single core is then
/// started with a data chunk. A list of all cores is
/// generated. Finally the command to collect and combine
/// the results of all cores is called.
/// </summary>
/// <remarks></remarks>
public void ExecuteMultiCore()
{
int intProcessorCores;
int intChunkSize;
ArrayList localData = new ArrayList();
int i;
int pC;
int pC2;
ArrayList dataChunk = new ArrayList();
try {
_MultiCoreList.Clear();
dataChunk.Clear();
intProcessorCores = Environment.ProcessorCount;
localData = this.MultiCoreData;
i = -1;
pC = -1;
intChunkSize = localData.Count / intProcessorCores;
foreach (System.Object Obj in localData) {
pC += +1;
pC2 += +1;
if (pC == intChunkSize | pC2 == localData.Count) {
dataChunk.Add(Obj);
StartCore(dataChunk);
dataChunk.Clear();
pC = 0;
}
else {
dataChunk.Add(Obj);
}
}
}
catch (Exception ex) {
throw ex;
}
finally {
localData = null;
}
}
private void CombineAllMultiCores()
{
foreach (Threading.Thread t in _MultiCoreList) {
t.Join();
}
}
private void StartCore(ArrayList wDataChunk)
{
Threading.Thread t = new Threading.Thread(MultiCoreProcess);
_MultiCoreList.Add(t);
t.Name = "CoreGuid_" + _MultiCoreList.Count;
t.Start(wDataChunk);
CombineAllMultiCores();
}
#endregion
}
do you really want to know?:
Code:using System.Threading; public class MultiCore { private ArrayList _MultiCoreData = new ArrayList(); private Threading.ParameterizedThreadStart _MultiCoreProcess; private ArrayList _MultiCoreList = new ArrayList(); #region "Public Properties" public ArrayList MultiCoreData { get { return _MultiCoreData; } set { _MultiCoreData = value; } } public Threading.ParameterizedThreadStart MultiCoreProcess { get { return _MultiCoreProcess; } set { _MultiCoreProcess = value; } } #endregion #region "MultiCore Class Constructor" public MultiCore(ArrayList wMultiCoreData, Threading.ParameterizedThreadStart wMultiCoreProcess) { this.MultiCoreData = wMultiCoreData; this.MultiCoreProcess = wMultiCoreProcess; } #endregion #region "MultiCore Processing" /// <summary> /// Execute MultiCore is the Main Class Method, /// the Execute starts the process initilization /// by first Flushing all the list of old cores /// if they exist, the number of processor cores /// is determined. Based on the size of the of the /// data and number of cores, the data is partitioned /// into smaller data chunks. A single core is then /// started with a data chunk. A list of all cores is /// generated. Finally the command to collect and combine /// the results of all cores is called. /// </summary> /// <remarks></remarks> public void ExecuteMultiCore() { int intProcessorCores; int intChunkSize; ArrayList localData = new ArrayList(); int i; int pC; int pC2; ArrayList dataChunk = new ArrayList(); try { _MultiCoreList.Clear(); dataChunk.Clear(); intProcessorCores = Environment.ProcessorCount; localData = this.MultiCoreData; i = -1; pC = -1; intChunkSize = localData.Count / intProcessorCores; foreach (System.Object Obj in localData) { pC += +1; pC2 += +1; if (pC == intChunkSize | pC2 == localData.Count) { dataChunk.Add(Obj); StartCore(dataChunk); dataChunk.Clear(); pC = 0; } else { dataChunk.Add(Obj); } } } catch (Exception ex) { throw ex; } finally { localData = null; } } private void CombineAllMultiCores() { foreach (Threading.Thread t in _MultiCoreList) { t.Join(); } } private void StartCore(ArrayList wDataChunk) { Threading.Thread t = new Threading.Thread(MultiCoreProcess); _MultiCoreList.Add(t); t.Name = "CoreGuid_" + _MultiCoreList.Count; t.Start(wDataChunk); CombineAllMultiCores(); } #endregion }
Its part of my multicore processing class I've been working on during the weekend, eventually this little thing will help DVXuser community *evil laugh* ..