I work with in-house legacy communication framework which exposes some high level abstractions. These abstractions are wrappers with some logic around .NET threads. When I looked at code I've noticed that 开发者_JAVA百科some abstractions are wrappers around foreground threads while others are wrappers around background threads.
The sad thing is that I don't see any logic why in some cases foreground threads are used and background in other cases.
Are there any guidelines or patterns & practices when it's better to choose one over another on server side and client side (I believe there should be some difference)?
Any examples from your own professional experience when it was crucial or just a good solution to prefer one over another?
Straight from MSDN
A managed thread is either a background thread or a foreground thread. Background threads are identical to foreground threads with one exception: a background thread does not keep the managed execution environment running. Once all foreground threads have been stopped in a managed process (where the .exe file is a managed assembly), the system stops all background threads and shuts down.
精彩评论