2
votes

I'm working on a mixed managed/native application using c++/CLI.

I know that the CLR will suspend all managed threads on (a clean) shutdown, but what about the unmanaged ones? Is it possible for the unmanaged threads to still be running, while the CLR runtime is shutting down/freeing memory/running finalizers?

2

2 Answers

1
votes

Note that the CLR will only suspend managed threads with property IsBackGround set to true. Any foreground threads that are still running will leave the application 'hanging' waiting for all foreground threads to finish.

As far as unmanaged threads are concerned, the CLR has no way of knowing about them, so yes, they will continue running unless you write code to terminate them.

May I ask why your application cannot shut down the threads gracefully at the point where it decides to terminate rather than leaving it up to the environment to do your cleanup?