PM.BLL/PMService.cs
/// <summary>
/// Handles cleanup actions when a device is lost
/// </summary>
/// <param name="args">Information about the lost device</param>
Handles cleanup actions when a device is lost
Handles cleanup actions when a device is lost
private void OnDeviceLost(object? _, EventArgs args)
        {
            if (args is not DeviceEventArgs deviceArgs)
            {
                throw new Exception($"Unexpected arguments in method [{nameof(OnDeviceLost)}]");
            }
            if (deviceArgs.SerialNumber == null)
            {
                _logger.LogCritical("Serial number was null when DeviceLost was acted on.");
                return;
            }
            try
            {
                if (_pmPollingService.IsActive(deviceArgs.SerialNumber))
                {
                    _pmPollingService.StopPolling(deviceArgs.SerialNumber);
                }
            }
            catch (Exception e)
            {
                _logger.LogWarning(e, "Attempted to stop polling for serial number [{SerialNumber}], but failed.", deviceArgs.SerialNumber);
            }
        }
private void OnDeviceLost ( object ? _ , EventArgs args ) { if ( args is not DeviceEventArgs deviceArgs ) { throw new Exception ( $" Unexpected arguments in method [ { nameof ( OnDeviceLost ) } ] " ) ; } if ( deviceArgs . SerialNumber == null ) { _logger . LogCritical ( " " ) ; return ; } try { if ( _pmPollingService . IsActive ( deviceArgs . SerialNumber ) ) { _pmPollingService . StopPolling ( deviceArgs . SerialNumber ) ; } } catch ( Exception e ) { _logger . LogWarning ( e , " " , deviceArgs . SerialNumber ) ; } }
Handles cleanup actions when a device is lost
Handles cleanup actions when a device is lost
// Close poll if active
_
object?
args
EventArgs
Information about the lost device
Information about the lost device