Hi, my requirement is to brake the MySQL database query into parts and execute each part within different threads for example
if user want to see the record from 1 to 1000 then query would be (Select * from record where rec_no > = 1 and rec_no <= 1000). Now instead of running this query I want to run 4 queries such as
1st query= (Select * from Record where rec_no > = 1 and rec_no <= 250)
2nd query = (Select * from Record where rec_no > = 251 and rec_no <= 500)
3rd query =(Select * from Record where rec_no > = 501 and rec_no <= 750)
4th query =Select * from Record where rec_no > = 751 and rec_no <= 1000)
this way all queries would take fraction of second and get executed parallel and fast.
I am getting result from all query but only facing problem to accumulate them in single array which would hold the result and reason behind that any thread would get executed first and return me the result.
part of my code is
private void btnStartThread_Click(object sender, System.EventArgs e)
{
Thread[] m_WorkerThread = new Thread[Environment.ProcessorCount];
for (int i = 0; i < Environment.ProcessorCount; i++)
{
m_WorkerThread[i] = new Thread(WorkerThreadFunction));
m_WorkerThread[i].Name = "Worker Thread Sample" + i;
m_WorkerThread[i].Start("querylist[i]");
}
}
private void WorkerThreadFunction( string s)
{
MyDefinedClass IClass;
lClass = new MyDefineClass();
Iclass.Run(s);
}
finally I am getting result in
private void AddString(array[] s)
{
final_array
}
Thanks in advance