Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to design a two-color ball number selection tool based on C#

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of how to design a two-color ball number selection tool based on C#, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this article on how to design a two-color ball number selection tool based on C#. Let's take a look.

Form display

Show after start

End the rocking show.

Code imported namespace using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;using System.Windows.Forms Initialize private variables private string [] red = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17"} Private string [] blue = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10"}; private bool begin = true Page initialization private void Form1_Load (object sender, EventArgs e) {foreach (var item in groupBox1.Controls) {if (item is Label) {((Label) item) .Text = "00" }} button2.Enabled = false;} start button private void button1_Click (object sender, EventArgs e) {button1.Text = "already started"; button1.Enabled = false; button2.Enabled = true; begin = true; TaskFactory f = new TaskFactory () List list = new List (); foreach (var item in groupBox1.Controls) {if (item is Label) {((Label) item). Text = "00" }} foreach (var item in groupBox1.Controls) {if (item is Label) {Label lbl = item as Label; list.Add (f.StartNew () = > {Random r = new Random ()) While (begin) {string txt = "" If (lbl.Name.Contains ("Red")) {lock (obj) {txt = red [r.Next (0,17)] Update (lbl, txt) }} else {txt = blue [r.Next (0,10)] Update (lbl, txt);} Thread.Sleep (10);}} f.ContinueWhenAll (list.ToArray (), tList = > this.ShowResult ()) } Digital update private void Update (Label label, string text) {this.Invoke (new Action () = > {label.Text = text;});} end button private void button2_Click (object sender, EventArgs e) {button1.Text = "start"; button1.Enabled = true Button2.Enabled = false; begin = false;} results show private void ShowResult () {StringBuilder s = new StringBuilder (); s.Append (lblRed1.Text + "); s.Append (lblRed2.Text +"); s.Append (lblRed3.Text +"); s.Append (lblRed4.Text +") S.Append (lblRed5.Text + "); s.Append (lblRed6.Text +"\ n "); s.Append ($" blueBob: {lblBlue.Text} "); MessageBox.Show (s.ToString ());} this article on" how to design a two-color ball number selection tool based on C # "ends here, thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to design a two-color ball number selection tool based on C#". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report