FluentModbus
FluentModbus copied to clipboard
Implement Disposable
I suggest to implement IDisposable. It is simpler to disconnect, if IDisposable is implemented.
When code gets complicated, you have two options:
- call
Disconnect()in multiple places - wrap all your code with try-finally and call
Disconnect()only once infinallyblock
I offer implement this. Do you agree and should I make a PR? 😉
Currently:
var client = new ModbusTcpClient();
// code here ...
// disconnect
client.Disconnect();
Suggestion:
using (var client = new ModbusTcpClient())
{
// code here ...
// will disconnect automatically
}
Good suggestion, please go ahead :-)
I has implemented it in v5, so I am closing this issue for now.