The application I am building is still running in memory (checked in Task Manager) after it is closed using Application.Exit(). Because of this when I am runnin
Because of using Foreground Thread and Lybda Expession thread So, threads which will continue to run until the last foreground thread is terminated. In another way, the application is closed when all the foreground threads are stopped. that's why the application won't wait until the background threads are completed, but it will wait until all the foreground threads are terminated. So In that case we have to explicitly stop the all running threads by using
Environment.Exit(Environment.ExitCode);
This kept the memory managed perfectly, with no memory leak.