Click here to Skip to main content
15,908,834 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to pass value to the function through thread... following is the original code without thread..

private void btnsearch_Click(object sender, EventArgs e)
{
SearchRecord(QuerySearch);
}

following is the code i m trying.. using thread..

private void btnsearch_Click(object sender, EventArgs e)
{
Thread Proceso1 = new Thread(new ThreadStart(load));
Proceso1.Start();

Thread Proceso2 = new Thread(new ThreadStart(loadTable ));
Proceso2.Start();

}

private void loadTable(int QuerySearch)
{

SearchRecord(QuerySearch);


}



public void load()
{

if (pictureBox1.InvokeRequired)
{
MethodInvoker assign = new MethodInvoker(load);
pictureBox1.Invoke(assign);

}
else
{
pictureBox1.Visible = true;

}
Thread.Sleep(100);
}



plz help me to pass value of querysearch through main thread to function
Posted

The Object that you pass into the Thread constructor (new Thread(Object) is intended for passing data to the thread. At some point before you call the Start method on the threads, use its properties to pass in your data.
 
Share this answer
 
Try:
C#
Thread myThread = new Thread(MethodName);
myThread.Start(ParameterObject);

So in your case it would be:
C#
Thread Proceso2 = new Thread(loadTable);
Proceso2.Start(QuerySearch);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900