Protocol: support user disposing handles that are sent
tmds opened this issue · comments
Tom Deseyn commented
Consider:
SafeHandle safeHandle = ...; // 1
messageWriter.WriteHandle(safeHandle);
connection.TrySendMessage(message); // 3
The library ensures that the safeHandle
passed in // 3 gets disposed.
When an exception occurs between //1 and //2 the safeHandle
won't get disposed.
We should allow the user to dispose the SafeHandle
:
using SafeHandle safeHandle = ...; // 1
This isn't supported currently because // 3 can return before the message was effectively sent, in that case we dispose the SafeHandle before sending it.