Relative Content

Tag Archive for c#multithreadingdispose

How is “IsDisposed” boolean reliable when in a disposed class?

Some Microsoft classes implemenet an “IsDisposed” boolean that indicates that a class is disposed. I inherit some of these classes and sometimes start headless threads from them with a while(true) loop on the inside. The threads are set to terminate by checking if IsDisposed in the class is set to True. But how reliable is this? If the class is disposed, then wouldn’t I lose access to the property ‘IsDisposed’ that sits inside the disposed class? Or will it remain undisposed because the Thread has a reference to the ‘IsDisposed’ property?