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#
are we all talking about the same .net here? just impliment
Finalizehttp://msdn.microsoft.com/en-us/library/b1yfkh5e(v=vs.100).aspx
http://msdn.microsoft.com/en-us/library/66x5fx1b.aspx
this is the way to tell the ‘GC’ to do some additional actions when clearing a resource.