I have some QueueClient / SubscriptionClients which are using the RegisterSessionHandler / RegisterSessionHandlerFactory methods to handle the session handling. I'm struggling to see how I can close all of this down gracefully.
At the moment, I just have to call the Close method of my QueueClient / SubscriptionClient. This causes chaos within by session handlers - some may be in the middle of processing a message, but won't be able to 'Complete' it, causing exceptions to throw and the message to be left on the queue. This also all seems to happen after the Close method returns, which means the handlers may be running after I've asked them to stop.
I had assumed 'Close' would first stop accepting sessions, let the current session handlers finally their current message, and then return... but that doesn't seem to be the case? Surely there is a better way to do this?