Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.linq;using system.text;using system.windows.forms;using system.threading;namespace windowsformsapplication2{public partial class Form1:form {public Form1 () {Initializeco Mponent (); private void Form1_Load (object sender, EventArgs e) {control.checkforillegalcrossthreadcalls = False } bool A; public void PlayGame () {Random rd = new Random (); while (a) {this.label1.Text = Rd. Next (0, 10). ToString (); This.label2.Text = Rd. Next (0, 10). ToString (); This.label3.Text = Rd. Next (0, 10). ToString (); }} private void Button1_Click (object sender, EventArgs e) {if (! a) {a=true; This.button1.Text = "pause"; Thread th = new Thread (playGame); Th. IsBackground = true; Th. Start (); } else {this.button1.Text = "start"; A = false; } } }}
The thread of C # is random