void RaiseInvokeCoinEvent(CoinAcceptorCoinEventArgs ea) { if (CoinAccepted != null) { CoinAccepted(this, ea); } }
void _coinAcceptor_CoinAccepted(object sender, CoinAcceptorCoinEventArgs e) { if (InvokeRequired) { Invoke((EventHandler<CoinAcceptorCoinEventArgs>)_coinAcceptor_CoinAccepted, sender, e); return; } _coinValue += e.CoinValue; txtLog.Text += String.Format("Coin accepted: {0} ({1:X2}), path {3}. Now accepted: {2}", e.CoinName, e.CoinCode, _coinValue, e.RoutePath) + Environment.NewLine; labTotalMoneyIn.Text = _coinValue.ToString(); CoinAccepted(e.CoinValue); // There is simulator of long-working event handler Thread.Sleep(1000); }
void CoinAcceptorCoinAccepted(object sender, CoinAcceptorCoinEventArgs e) { if (InvokeRequired) { Invoke((EventHandler<CoinAcceptorCoinEventArgs>)CoinAcceptorCoinAccepted, sender, e); return; } _coinCounter += e.CoinValue; listBox1.Items.Add(String.Format("Coin accepted: {0} ({1:X2}), path {3}. Now accepted: {2:C}", e.CoinName, e.CoinCode, _coinCounter, e.RoutePath)); listBox1.SelectedIndex = listBox1.Items.Count - 1; //listBox1.SelectedIndex = -1; // There is simulator of long-working event handler Thread.Sleep(1000); }
void RaiseInvokeCoinEvent(CoinAcceptorCoinEventArgs ea) { if (CoinAccepted != null) CoinAccepted(this, ea); }