public async Task RegisterPacketCaptureAsync(Action <DomainPacket> packetCallback, Action <DomainDeviceError> deviceCallback) { callback = packetCallback; DomainDeviceError deviceMessage = new DomainDeviceError(); try { devices = CaptureDeviceList.Instance; } catch { // Most likely reason is WinPCAP is not installed deviceMessage.NoDevicesError = true; deviceCallback(deviceMessage); return; } await devices.ForEachAsync(device => { try { deviceMessage.DeviceName = device.Description; device.OnPacketArrival += OnDevicePacketArrival; device.Open(DeviceMode.Normal, 1000); device.Filter = "(ip or ip6) and (tcp or udp)"; device.StartCapture(); deviceMessage.DeviceLoaded = true; initialized = true; } catch { deviceMessage.DeviceLoaded = false; } deviceCallback(deviceMessage); return(Task.CompletedTask); }).Fire(); }