public void AddToken(string cardKey, string tokenKey, string text, int amount, TokenColor color) { AddTokenArgs args = new AddTokenArgs() { CardKey = cardKey, TokenKey = tokenKey, Amount = amount, Text = text, Color = color }; if(InvokeRequired) Invoke(new Action<AddTokenArgs>(AddToken), args); else { try { AddToken(args); } catch(Exception ex) { HandleException(ex); } } }
void AddToken(AddTokenArgs args) { foreach(CardView card in Controls.Find(args.CardKey, true)) card.AddToken(args.TokenKey, args.Text, args.Amount, args.Color); }