I am dynamically generating some labels with the help of data from the database. Then I added some events to these dynamically generated labels. I am trying to run the click events of labels in a new thread. But I couldn't figure it out so far. Any leads will be really helpful.
private void LoadData(string DeviceCode)
{
//here i am generating the labels (not shown)
//adding the event handler
lb_DeviceData[i].Click += new EventHandler(CalculateClick);
lb_DeviceData[i]..Tag = i;
}
private void CalculateClick(object sender, EventArgs e)
{
Label MyLabel = (Label)sender;
Thread t = new Thread(ThreadedMethodForCalc); //can i pass MyLabel into this method?
t.Start();
}
private void ThreadedMethodForCalc()
{
//complex calculation here
// is it possible to pass 'MyLabel' in this method
}