public partial class frmSSQ : Form { public frmSSQ() { InitializeComponent();
this.btnStart.Enabled = true; this.btnStop.Enabled = false; } #region Data ///
<summary> /// Red ball set It can be written to the configuration file /// </summary> private string[] RedNums = { "01",
"02","03","04","05","06","07","08","09","10", "11","12","13","14","15","16","17"
,"18","19","20", "21","22","23","24","25","26","27","28","29","30", "31","32",
"33" }; /// <summary> /// Basketball collection /// </summary> private string[] BlueNums = { "01"
,"02","03","04","05","06","07","08","09","10", "11","12","13","14","15","16" };
private bool IsGoOn = true; private List<Task> taskList = new List<Task>(); #
endregion #region UI /// <summary> /// Click start : /// </summary> /// <param
name="sender"></param> /// <param name="e"></param> private void btnStart_Click(
object sender, EventArgs e) { try { #region Initialization action this.btnStart.Text = " function ing";
this.btnStart.Enabled = false; this.IsGoOn = true; this.taskList = new List<Task
>(); this.lblBlue.Text = "00"; this.lblRed1.Text = "00"; this.lblRed2.Text =
"00"; this.lblRed3.Text = "00"; this.lblRed4.Text = "00"; this.lblRed5.Text =
"00"; this.lblRed6.Text = "00"; #endregion Thread.Sleep(1000); foreach (var
controlin this.gboSSQ.Controls) { if (control is Label) { Label label = (Label)
control; if (label.Name.Contains("Blue")) { taskList.Add(Task.Run(() => { try {
while (IsGoOn) { //1 Get random number int index = new RandomHelper().GetRandomNumberDelay(0
, 16); string sNumber = this.BlueNums[index]; //2 Update interface //this.lblBlue.Text =
sNumber; // Child threads cannot manipulate controls , Delegate to main thread operation //this.Invoke this.Invoke(new Action(() => { label
.Text = sNumber; })); //3 loop } } catch (Exception ex) { Console.WriteLine(ex.
Message); } })); } else if (label.Name.Contains("Red")) { taskList.Add(Task.Run(
() => { try { while (IsGoOn) { int index = new RandomHelper().
GetRandomNumberDelay(0, 33); string sNumber = this.RedNums[index]; // It may be repeated You have to get rid of the weight
//1 A pawn crossing the river Take it all at once 6 individual , One update , However, the interface update is regular //2 Another array tag , A little clumsy ; In fact, the interface does not have ? //3 80 struggle
Data separation , Safe and efficient , But there are rules // Is the test repeated , Direct comparison interface // Get random Comparison interface to update lock (SSQ_Lock) { List<string>
usedNumberList= this.GetUsedRedNumbers(); if (!usedNumberList.Contains(sNumber))
{ this.Invoke(new Action(() => { //Thread.Sleep(10); label.Text = sNumber; }));
// It's actually synchronous } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } })); }
} } Task.Factory.ContinueWhenAll(this.taskList.ToArray(), tArray => { this.
ShowResult(); this.Invoke(new Action(() => { this.btnStart.Enabled = true; this.
btnStop.Enabled = false; })); }); Task.Delay(10 * 1000).ContinueWith(t => { this
.Invoke(new Action(() => { this.btnStop.Enabled = true; })); }); } catch (
Exception ex) { Console.WriteLine(" Abnormal start of bicolor :{0}", ex.Message); } } private
static readonly object SSQ_Lock = new object(); private List<string>
GetUsedRedNumbers() { List<string> usedNumberList = new List<string>(); foreach
(var controler in this.gboSSQ.Controls) { if (controler is Label) { if (((Label)
controler).Name.Contains("Red")) { usedNumberList.Add(((Label)controler).Text);
} } } return usedNumberList; } /// <summary> /// Click finish /// </summary> /// <param
name="sender"></param> /// <param name="e"></param> private void btnStop_Click(
object sender, EventArgs e) { this.IsGoOn = false; } /// <summary> /// Pop up prompt data
/// </summary> private void ShowResult() { MessageBox.Show(string.Format(
" The results of this study were as follows :{0} {1} {2} {3} {4} {5} blue ball {6}" , this.lblRed1.Text , this.lblRed2.Text
, this.lblRed3.Text , this.lblRed4.Text , this.lblRed5.Text , this.lblRed6.Text
, this.lblBlue.Text)); } #endregion #region PrivateMethod #endregion }

Technology
©2019-2020 Toolsou All rights reserved,
Digital rolling lottery program Keras Save and load model (JSON+HDF5) Remember once EventBus Project issues caused by memory leaks I've been drinking soft water for three years ? What is the use of soft water and water softener msf Generate Trojan horse attack android mobile phone Time conversion front desk will 2020-07-17T03:07:02.000+0000 Into 2020-07-17 11:07:02 Chuan Shen 1190 Reverses the substring between each pair of parentheses leetcodehive Summary of processing methods for a large number of small files SparkSQL Achieve partition overlay write Image format conversion