Apollo3zehn / FluentModbus

Lightweight and fast client and server implementation of the Modbus protocol (TCP/RTU).
MIT License
189 stars 71 forks source link

Implement Disposable #67

Closed taai closed 1 year ago

taai commented 2 years ago

I suggest to implement IDisposable. It is simpler to disconnect, if IDisposable is implemented.

When code gets complicated, you have two options:

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
}
Apollo3zehn commented 2 years ago

Good suggestion, please go ahead :-)

Apollo3zehn commented 1 year ago

I has implemented it in v5, so I am closing this issue for now.