have a look at the pattern used e.g. in the VL.IO.TCP’s TCPServer class. it involves a SerialDisposable. whenever you set NULL to the SerialDisposable it will dipose the Disposable you handed it earlier.
so you’ll see in the patch that inside the cache region you always make two calls to the SerialDisposable’s SetDisposable:
first you set it to NULL (ie. calling the previous disposable)
then you set the new disposable
and then don’t forget to dispose the SerialDisposable itself when the patch disposes