In my code, I have a class which create a new thread. This new thread has a Dispatcher, thus the thread will not finish unless I call
Dispatcher.CurrentDispatcher.InvokeShutdown();
The thread cannot be referenced outside of my class. So I was thinking : how to ensure that my thread finish when my object is garbage collected ?
One response is to use IDisposable, but if someone forget to call Dispose(), the thread will never stop so it's not a solution.
Another response is two use Dispose + Destructor, but I've heard that we should only use the destructor for release unmanaged resource. I'm in a dead end.
What is the best solution ?