Disposing a form does not affect your flows.
Your code is clearly incomplete (e.g. MyControl cls = new MyClass();
and we don’t know what doWork
or doOtherJob
), but I suspect that part of the problem is that you have only one thread variable.
Each time the timer goes off, you do thd = new Thread
twice. If your timer goes off ten times, then thd
points to your last thread, but there are 19 other threads that are still running, and any of them can support your application.
One thing that can help is to explicitly set .IsBackground
to true
in the threads you create, as this will help to terminate them when your user interface thread closes. However, I would advise that creating this large number of threads in this way is most likely not an efficient model, and you'd better reconsider your design to run only one or two workflows instead of kicking dozens.
source share