using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespaceWindowsFormsApp1 { publicpartialclassForm1 : Form { publicForm1() { InitializeComponent(); } privatevoidForm1_Load(object sender, EventArgs e) { ThreadStart ts1 = new ThreadStart(A); Thread t1 = new Thread(ts1); t1.Start(); ThreadStart ts2 = new ThreadStart(B); Thread t2 = new Thread(ts2); t2.Start(); } publicvoidA() { for (int i = 0; i < 20; i++) { Thread.Sleep(1000); //label1.Text = i.ToString(); Invoke(new Action(() => label1.Text = i.ToString())); } } publicvoidB() { for (int i = 0; i < Convert.ToInt16(label2.Text); i++) { Thread.Sleep(1000); Invoke(new Action(() => label2.Text = (Convert.ToInt16(label2.Text) - 1).ToString())); } } } }