What happens to a thread if it is running a method in an object that was freed by exiting a using block?
Example:
using (SomeObject obj = new SomeObject ()) { obj.param = 10 ; Thread newThread = new Thread(() => { obj.Work(); }); newThread.Start(); } ...
obj.Work() is running on a new thread but obj is an IDisposable object that would normally get released when the using block exits. What happens if the thread continues running after the using block ends? Will the object get disposed only after the thread completes? Or will the thread break?
Thanks.