Cache Region: Executing Nodes on disposal

Is it possible to call nodes on “auto dispose” for cache regions? (Similar to manually calling dispose like on process nodes.
grafik

usecase would be to cleanly stop a service that is created in a cache region before recreating it…
grafik
i don’t see any option to do this right away…

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

it’s really not as difficult as this may sound.

1 Like

i think i got the concept - thanks for the example and explanation, i’d never figured this out by myself. this should probably go the graybook too.