I'm having a bit of a brain-freeze so I thought I'd throw this out there to the collective genius of SO...
I have an event that is raised (this will be on the thread of the "raiser") and I consume it.
However, once I am handling this event, I need to fire off another thread to perform the workload that the event signified. So, I'm using:
private void MyEventHandler(object sender, EventArgs e)
{
Thread t = new Thread(new ThreadStart(MyHandler));
t.Start();
}
private void MyHandler()
{
DoStuff(); // takes a long time
}
My question is: Do I need to be concerned about the lifecycle of the variable t
? i.e. Can t
be garbage collected, thus aborting the work being performed in DoStuff()
?