Exemplo n.º 1
0
        private static void Instance_DeviceDeleted(object sender, DeviceDeletedEventArgs e)
        {
            var t = Thread.CurrentThread.ManagedThreadId;

            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                var mainWindow = (MainWindow)Application.Current.MainWindow;
                mainWindow.ListBoxTest.Items.Add("Device deleted: Serial number - " + e.SerialNumber + " : thread - " + t);
                mainWindow.Devices.Remove(e.Device);
            }));
        }
Exemplo n.º 2
0
 public void Delete(string serialNumber)
 {
     lock (lockObj)
     {
         var device = devices.Where(r => r?.SerialNumber == serialNumber).FirstOrDefault();
         DeviceDeletedEventArgs e = new DeviceDeletedEventArgs()
         {
             SerialNumber = device?.SerialNumber, Device = device
         };
         OnDeviceDeleted(e);
         devices.Remove(device);
     }
 }
Exemplo n.º 3
0
 protected virtual void OnDeviceDeleted(DeviceDeletedEventArgs e)
 {
     DeviceDeleted?.Invoke(this, e);
 }