I went through a similar problem in my software, but unfortunately, just forcing the threads to run in the background, this did not solve the problem. In fact, when the stream returns data (the main software is data driven), and if I close the application, it will result in a Windows error, which will lead to debugging of the message.
So what actually worked for me:
Step 1: Made all the threads in the background, e.g.
Thread aThread = new Thread(MethodName); aThread.IsBackground = true;
Step 2: In the final form / application action, the Environment.Exit method is called, for example
Environment.Exit(Environment.ExitCode);
This ensured that the memory worked correctly without memory leak.
Hope this helps.
Somdip Dey __Company_Profile__ Jun 02 '17 at 14:51 2017-06-02 14:51
source share