Question : C# Threading Issue

I'm writing a program in C# using .NET Framework 3.5
When my program is run, I need it to perform tasks and start threads to do other tasks then close. When it closes the other threads may not be done yet, so I need a way to have them continue to execute until they are complete.

I'm new to threading and I'm not even not sure if there is a way to do this.

Thanks in advance,
Brandon

Answer : C# Threading Issue

If you create a MANUAL thread and do NOT set the IsBackground() Property to True (it's False by default) then the app will NOT completely close until the threads complete.  The main Form may not be visible anymore but the app will still be running...check the Task Manager.

See: http://msdn.microsoft.com/en-us/library/system.threading.thread.isbackground.aspx

    "true if this thread is or is to become a background thread; otherwise, false."

    "A thread is either a background thread or a foreground thread. Background threads are identical to foreground threads, except that background threads do not prevent a process from terminating. Once all foreground threads belonging to a process have terminated, the common language runtime ends the process. Any remaining background threads are stopped and do not complete."
Random Solutions  
 
programming4us programming4us