public void DisplayPlate(LicencePlate plate) { MethodInvoker invoker = delegate { DisplayVehicleCount(plate); //lvResults.Items.Add(new ListViewItem(plate.toArray())); lvResults.Items.Insert(0, new ListViewItem(plate.toArray())); lvResults.Items[0].BackColor = plate.plateNumber.Contains("error") ? Color.Red : Color.LawnGreen; }; BeginInvoke(invoker); }
public void DisplayVehicleCount(LicencePlate plate) { MethodInvoker invoker = delegate { statsDataGrid.Rows[0].Cells[1].Value = _vehicleCount; if (plate.isRegistered) { int count = Convert.ToInt32(statsDataGrid.Rows[1].Cells[1].Value.ToString()); statsDataGrid.Rows[1].Cells[1].Value = ++count; } else { int count = Convert.ToInt32(statsDataGrid.Rows[2].Cells[1].Value.ToString()); statsDataGrid.Rows[2].Cells[1].Value = ++count; } }; BeginInvoke(invoker); }