void BillValidatorNotesAccepted(object sender, DeviceMoneyEventArgs e) { if (InvokeRequired) { Invoke((EventHandler<DeviceMoneyEventArgs>)BillValidatorNotesAccepted, sender, e); return; } _notesCounter += e.MoneyValue; listBox1.Items.Add(String.Format("Bill accepted: {0} ({1:X2}), path {3}. Now accepted: {2:C}", e.MoneyName, e.MoneyCode, _notesCounter, e.RoutePath)); listBox1.SelectedIndex = listBox1.Items.Count - 1; //listBox1.SelectedIndex = -1; // There is simulator of long-working event handler Thread.Sleep(1000); }
/// <summary> /// Raises a success event while accepting money /// </summary> /// <param name="moneyEvent">Info of the success event to raise</param> protected void RaiseInvokeMoneyEvent(DeviceMoneyEventArgs moneyEvent) { if (MoneyAccepted != null) { MoneyAccepted(this, moneyEvent); } }