shayhatsor / zookeeper

Apache ZooKeeper .NET async Client
https://nuget.org/packages/ZooKeeperNetEx/
Apache License 2.0
236 stars 53 forks source link

Implement IDisposable pattern for ZooKeeper handle #50

Open jabellard opened 2 years ago

jabellard commented 2 years ago

This enhancement implements the IDisposable pattern for the ZooKeeper handle. This is useful for scenarios where a newly created handle is to be used transiently, and consequently should not have its connection persist beyond that use. With this change, the handle can now be used transiently like so:

public async Task InteractWithZooKeeper()
{
    using var zooKeeperHandle = new ZooKeeper(...);
    var dataResult = await zooKeeperHandle.getDataAsync("/");
    Console.WriteLine("Got data!");
}