public int crstak(int start, int rk) { //создание стакана Random rnd = new Random(); rnd = new Random(); Quote[] quotes = new Quote[40]; int del = rnd.Next(0, 3); int delta = 0; int lq = start; if (del == 1) { delta = 1; } else { delta = -1; } if (lq == 0) { lq = start; } else { lq = lq + delta; } int ask = -1, bid = -1; for (int i = 0; i < 40; i++) { int p = lq, av = 0, bv = 0, sc = 0; if (i < 20) { // rnd = new Random(); av = rnd.Next(10, 1000); p = p - i; ask = i; quotes[i] = new Quote(p, av, QuoteType.Ask); } else { bv = rnd.Next(10, 1000); p = p - i; bid = i; quotes[i] = new Quote(p, bv, QuoteType.Bid); } } if (quotes[0].Price <= quotes[1].Price) { Trace.WriteLine("стакан перевернут"); } quotes[ask].Type = QuoteType.BestAsk; quotes[ask + 1].Type = QuoteType.BestBid; Application.Current.Dispatcher.InvokeAsync(() => { textb2.Text = "Запись Стакан"; }); foreach (var item in quotes) { Application.Current.Dispatcher.InvokeAsync(() => { textb2.Text = textb2.Text + "\n" + item.Price.ToString() + " " + item.Volume.ToString() + " " + item.Type.ToString();; }); } //запись стакана if (rk == 1) { recorder.AddStock(quotes, new Spread(quotes[ask].Price, quotes[bid].Price), recorder); } else { recorder1.AddStock(quotes, new Spread(quotes[ask].Price, quotes[bid].Price), recorder1); } return(lq); }