using System; using System.Threading; using System.Drawing; using System.Windows.Forms; public partial class CounterForm : Form { private int count = 0; private int threadCount; public CounterForm(int tc) { InitializeComponent(); threadCount = tc; } public void Count() { do { count++; Thread.Sleep(10); countLabel.Text = "Count= " + count; if (threadCount == 0) BackColor = Color.Blue; else if (threadCount == 1) BackColor = Color.Yellow; else if (threadCount == 2) BackColor = Color.Red; else BackColor = Color.Green; Invalidate(); } while (true); } }