Exemplo n.º 1
0
        protected void RaiseDeviceFound(NatDevice device)
        {
            CurrentSearchCancellation?.Cancel();

            NatDevice actualDevice;

            lock (Devices) {
                if (Devices.TryGetValue(device, out actualDevice))
                {
                    actualDevice.LastSeen = DateTime.UtcNow;
                }
                else
                {
                    Devices[device] = device;
                }
            }
            // If we did not find the device in the dictionary, raise an event as it's the first time
            // we've encountered it!
            if (actualDevice == null)
            {
                DeviceFound?.Invoke(this, new DeviceEventArgs(device));
            }
        }