Is there any way to add an event to the current thread that is executed when the thread ends.
I have a solution where we create resources that we want to re-use but still need to have disposed when the thread ends to prevent leaks and I cannot trust every one to be diligent in adding manual dispose calls to their code.
I could do this with a wrapper around the thread but that will not be a reliable solution as I will not be able to make 100 % sure every one would use the wrapper and sometimes this might need to be added into an existing thread.
So I would need my resource to be able to add a dispose event to be called when the tread finishes.
Is this possible in C#