private static void Cleanup() { // stop the service and cleanup service.Stop(); service.Dispose(); service = null; }
static void Main() { ConsoleKeyInfo key; service = new DiscoveryService(); // register for events service.DeviceUpdatedEvent += Iot_DeviceUpdatedEvent; service.DeviceDiscoveredEvent += Iot_DeviceDiscoveredEvent; service.DeviceRemovedEvent += Iot_DeviceRemovedEvent; service.ConnectionExceptionEvent += DiscoveryService_ConnectionExceptionEvent; // start the discovery service service.Start(); // if the user press 'c' start cleaning up and exit Console.WriteLine("Press 'c' to cancel listening"); do { key = Console.ReadKey(); } while (key.KeyChar != 'c'); }