Start a thread and forget about it?

  • Thread starter Thread starter Carl
  • Start date Start date
C

Carl

Hi,

Is it OK to start at thread so it does its work, and just forget about it.
Will it automatically dissapear when it is done? For exampel, like this:

Thread t = new Thread(ReportingForm.StartProcessingReports);
t.SetApartmentState(ApartmentState.STA);
t.Start();

No Join or anything like that.

regards

Carl
 
Carl said:
Is it OK to start at thread so it does its work, and just forget about it.
Absolutely.

Will it automatically dissapear when it is done? For exampel, like this:

Thread t = new Thread(ReportingForm.StartProcessingReports);
t.SetApartmentState(ApartmentState.STA);
t.Start();

No Join or anything like that.

Looks fine to me.

You might want to think about whether the thread should keep the
process alive if all the other foreground thread dies - if not, set
IsBackgroundThread to true.
 
Jon Skeet said:
Looks fine to me.

You might want to think about whether the thread should keep the
process alive if all the other foreground thread dies - if not, set
IsBackgroundThread to true.

Great, and thanks for the tip about the IsBackgroundThread!
 
Back
Top