public void crorder(int pric, int rk) { long id = 123123; Random rnd = new Random(); int qty = rnd.Next(1, 20); if (rk == 1) { recorder.AddOrder(id, pric, qty, recorder); } else { recorder2.AddOrder(id, pric, qty, recorder2); } Application.Current.Dispatcher.InvokeAsync(() => { textb3.Text = "\n" + pric.ToString() + " " + qty.ToString(); }); }