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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top