private void button2_Click(object sender, EventArgs e) { CityEventNews lviv = new CityEventNews(); lviv.media += formTV.Update; lviv.media += formRadio.Update; //new Thread(GenerateNews).Start(lviv); new Thread(() => GenerateNews(lviv)).Start(); }
private void GenerateNews(object obj) { CityEventNews city = obj as CityEventNews; if (city != null) { for (int i = 0; i < 20; i++) { city.OnUpdate(new News { Info = "Cold" }); Thread.Sleep(200); } } }
private void button1_Click(object sender, EventArgs e) { CityEventNews kiev = new CityEventNews(); kiev.media += formTV.Update; kiev.media += formRadio.Update; kiev.media += formPaper.Update; //new Thread(GenerateNews).Start(kiev); new Thread(() => { if (kiev != null) { for (int i = 0; i < 20; i++) { kiev.OnUpdate(new News { Info = "Cold" }); Thread.Sleep(200); } } }).Start(kiev); }