public void FindDeviceAround() { try { Message MsgSent = new Message(); List <Device> devicesFound = new List <Device>(); while (true) { devicesFound.Clear(); MsgSent.Pin = Utils.GeneratePin(); MsgSent.DeviceName = Utils.GetDeviceName(); UdpMulticastSend(MsgSent); CallWithTimeout(() => { while (true) { WaitMessage( (msg) => msg.Type == MsgType.Info && msg.Pin == MsgSent.Pin, (remote, msg) => devicesFound.Add(new Device { Addr = remote.Address.ToString(), Name = msg.DeviceName })); } }, 3000); OnDeviceFound?.Invoke(devicesFound); } } catch (OperationCanceledException) { } }