Question: 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.

```cs
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
}          

```

Answer: 
Well, the simplest way is to change the signature of the method and use [closure](https://stackoverflow.com/questions/595482/what-are-closures-in-c):

```
Thread t = new Thread(() => ThreadedMethodForCalc(MyLabel));
t.Start();

...

private void ThreadedMethodForCalc(Label myLabel)
{
}

```

Btw to update the UI in another thread you can use `Control.Invoke(...)`. 

For more information check [this article](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.invoke?view=netframework-4.8) from MSDN.
Yo can your method accepting label

```cs
private void ThreadedMethodForCalc(object label)
{
    Label MyLabel = (Label)label;
    //complex calculation here
    // is it possible to pass 'MyLabel' in this method
} 

```

And then use in thread `Start`

```
t.Start(sender);

```

But you aren't allowed to modify the control properties outside the UI thread