Microsoft.Azure.Devices.ServiceClient
and Microsoft.Azure.Devices.RegistryManager
both have ConnectFromConnectionString
and CloseAsync
methods.
Should we use them like we use other .NET connection-close
patterns, such as ADO.NET connections, Redis connections, Sockets' etc.? When I use objects like those I try to Close
or Disposable.Dispose()
of them as soon as possible.
What's the upside and downside to doing the same with the Microsoft.Azure.Devices
objects when accessing the same IOT Hub? I have running code that treats the individual RegistryManager
and ServiceClient
instances as singletons, which are used throughout an application's lifetime -- which may be weeks or months. Are we short circuiting ourselves by keeping these objects "open" for this duration?